home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
lang_c
/
tclib20
/
tchk.doc
< prev
next >
Wrap
Text File
|
1988-12-03
|
346KB
|
17,097 lines
TCHK - a Turbo C library
Version 2.00
Documentation for TCHK
by
Howard Kapustein
Howard Kapustein
1695 Barbara Lane
East Meadow, NY 11554
(516) 481-9612
(c) Copyright 1987, 1988, All rights reserved
TCHK 2.0 Page 1
Table of Contents
COPYRIGHT AND DISCLAIMER .......................................... 7
TRADEMARKS ........................................................ 7
LICENSE ........................................................... 7
BACKGROUND ........................................................ 8
FILES ............................................................. 9
IN THE BEGINNING.. ................................................ 10
FEATURES .......................................................... 11
CREDIT ............................................................ 11
FUNCTIONS ......................................................... 11
accum_dep - calculate accumulated depreciation ............... 14
ansi_call - create an ANSI escape sequence ................... 15
ansiback - convert DOS background code to ANSI ............... 17
ansifore - convert DOS foreground code to ANSI ............... 18
atrim - trims leading and trailing blanks .................... 19
average - calculate the average of a set of reals ............ 20
beep - generate a standard IBM PC beep ....................... 21
box - draw a box ............................................. 22
boxwindow - draw a 'window' .................................. 23
Cal... - family of Calendar date conversions ................. 25
CapsLock - set the Caps Lock key state ....................... 26
changelitebar - set internal litebar menu ................... 27
clear - clears a portion of the screen ....................... 28
clear_typeahead - clear typeahead buffer ..................... 29
cls - clear screen ........................................... 30
color - make a single attribute .............................. 31
cpu_id - identify the cpu .................................... 32
cursor_blink - set speed of cursor blink ..................... 33
cursor_flip - toggle the cursor type ......................... 34
cursor_off - turn the cursor off ............................. 35
cursor_on - turn the cursor on ............................... 36
date_convert - convert date formats .......................... 37
dayofweek - find the day of the week ......................... 38
dayofyear - calculate the day of the year .................... 39
daysleft - calculate the days left in the year ............... 40
ddatetofull - convert a date to full string .................. 41
ddatetoshort - convert a date to short string ................ 42
ddatetostr - convert a date to abbrev. string ................ 43
depreciation - calculate depreciation for a .................. 44
DESQcommonmem - returns measure of common memory ............. 45
DESQconvenmem - returns measure of conventional .............. 46
DESQdispchar - displays a char on the status line ............ 47
DESQexit - exit program in DESQview .......................... 48
DESQexpandedmem - returns measure of expanded ................ 49
TCHK 2.0 Page 2
DESQfreeCPU - give up CPU time ............................... 50
DESQInternalStack - switch to DESQview's internal ............ 51
DESQMakeTone - makes a tone under DESQview ................... 52
DESQProgramStack - switch back to program's ................. 53
DESQversion - DESQview version ............................... 54
diffddate - calculate the difference in 2 dates .............. 55
diskchanged - has the disk has been changed .................. 56
disktype - identify disk type ................................ 57
dosday - extract day from file date stamp .................... 58
doshour - extract hour from file time stamp .................. 59
dosmonth - extract hour from file date stamp ................. 60
dosmin - extract minutes from file time stamp ................ 61
dossec - extract seconds from file time stamp ................ 62
dosyear - extract year from file date stamp .................. 63
double_decline_bal_dep - calculate double .................... 64
DoubleDOSfreeCPU - give up CPU time under .................... 65
DoubleDOSGetVirtual - get DoubleDOS virtual .................. 66
DoubleDOSTaskSwitch - set Double DOS task .................... 67
EMMversion - version of Expanded Memory Manager .............. 68
EMSinfo - determines EMM version and EMS pages ............... 69
EMSpages - determines the total and available ................ 70
EMSwarmbootprep - prepares the EMM for warm boot ............. 71
endstri - get offset to last char of a string ................ 72
endstrp - get pointer to last char of a string ............... 73
expandfilespec - expand a filespec into a full ............... 74
Extendedtotal - total Extended memory installed .............. 75
factorial - determines a factorial (n!) ...................... 76
fname_match - compare filenames w/wildcards .................. 77
fncmp - compare filenames w/wildcards ........................ 78
frac - round the fractional portion of a real ................ 79
fsgn - sign of a real ........................................ 80
fulltoddate - convert a full date to struct .................. 81
FV - calculate the Future Value of a single amount ........... 82
FVa - calculate the Future Value of an annuity ............... 83
getBootBlock - get Boot Block ................................ 84
getBPB - get Bios Parameter Block ............................ 85
getc_match - get specific input, case dependent .............. 86
getci_match - get specific input, case ....................... 87
getcursor - gets cursor scan lines ........................... 88
getdatehk - inputs a date from the keyboard .................. 89
getdouble - inputs a double from the keyboard ................ 90
getEMSstatus - get Expanded Memory status .................... 91
getfilespec - get a DIR proper filespec ...................... 92
getfname - get a filename from the keyboard .................. 93
getget - get a string from the keyboard w/editing ............ 94
getint - inputs an integer from the keyboard ................. 96
getk - get a key ............................................. 97
getlogical - get Yes/No ...................................... 98
getreal - inputs a real from the keyboard .................... 99
getstr - input a string from the keyboard .................... 100
getyn - get Yes/No ........................................... 101
gotohv - move cursor to absolute coordinates ................. 102
Greg... - family of Gregorian date conversion ................ 103
horiz_line - draw a horizontal line .......................... 104
TCHK 2.0 Page 3
inkey - get a key ............................................ 105
inkeyc - get a key, any alphabetics capitalized .............. 106
intlen - calculate length of integer in a string ............. 107
InsLock - set the Insert key state ........................... 108
isAppendavail - is APPEND installed .......................... 109
isAssignavail - is ASSIGN installed .......................... 110
isBlogical - is drive B: logical ............................. 111
isBREAKon - check Ctrl-BREAK flag ............................ 112
isCGA - is Color Graphics adapter installed .................. 113
isEGA - is Enhanced Graphics adapter installed ............... 113
isHerc - is Hercules Graphics adapter installed .............. 113
isMDA - is Monochrome adapter installed ...................... 113
ismono - is monochrome display ............................... 113
iscolor - is color display ................................... 113
isdir - is a FAT entry a subdirectory ........................ 114
isEMSavail - is EMS available ................................ 115
isExtended - is Extended memory installed .................... 116
isgameport - is a game port installed ........................ 117
isgn - sign of an integer .................................... 118
iskey102 - is an enhanced keyboard installed ................. 119
isleapyear - is a year a leap year ........................... 120
isNetwork - is a network installed ........................... 121
isPRINTavail - is PRINT.COM installed ........................ 122
isPM - the the hour AM or PM ................................. 123
isShareavail - is SHARE installed ............................ 124
isVERIFYon - check VERIFY flag ............................... 125
isVidclock - is VIDCLOCK.COM by Tom Hanlin ................... 126
Jul... - family of Julian date conversion .................... 127
leftstr - return the left portion of a string ................ 128
litebar_alloc - allocate memory for a litebar ................ 129
litebar_free - frees memory allocated by a ................... 133
litebar_get - get user's choice from a litebar ............... 134
litehilite - hilite a litebar menu command ................... 135
litemessage - change the message for a litebar ............... 136
liteunlite - unhilite a litebar menu command ................. 137
lsgn - sign of a long integer ................................ 138
ltrim - trims leading blanks ................................. 139
lotus_setup - creates info for menu_lotus() .................. 140
machine_id - determine machine type .......................... 141
memory_strategy - get/set memory alloc strategy .............. 142
menu_lotus - Lotus style menu ................................ 143
menu_popup - popup style menu ................................ 145
mid - is a number within a range ............................. 146
midstr - return the middle portion of a string ............... 147
monthexpand - convert a month abbrev to its name ............. 148
ndp_id - identify the math coprocessor ....................... 149
NumLock - set the Num Lock key state ......................... 150
parsefilename - parses a filename, supports paths ............ 151
parsefnameext - parses a filename into name and .............. 153
pause - wait for a time or until a keypress .................. 154
PMT - calculate the periodic payment required to ............. 155
popup_alloc - allocate memory for a popup menu ............... 156
popup_free - frees memory allocated by popup menu ............ 159
popup_get - get user's choice from a popup menu .............. 160
TCHK 2.0 Page 4
popup_restore - restore video from a popup menu .............. 161
popup_setcurrent - set internal popup menu ................... 162
pophilite - hilite a popup menu command ...................... 163
popunlite - unhilite a popup menu command .................... 164
print_screen - issue a PrintScreen ........................... 165
PRINTadd - add a file to the print queue ..................... 166
PRINThold - hold print queue for status read ................. 167
PRINTpurge - remove all files from print queue ............... 168
PRINTremove - remove a file from print queue ................. 169
PRINTresume - resume printing after a PRINThold .............. 170
putk - put a character w/attribute on the screen ............. 171
putsay - put a string with attribute on the .................. 172
putstr - put string with attribute on the screen ............. 173
PV - calculate the Present Value of a single ................. 174
PVa - calculate the Present Value of an annuity .............. 175
read_attrib - gets the attribute under the cursor ............ 176
read_char - gets the character under the cursor .............. 177
read_cursor - reads cursor information ....................... 178
read_mode - find screen width, mode and page ................. 179
reboot - reboots the machine ................................. 180
rightstr - return the right portion of a string .............. 181
ROM_date - gets the ROM id date .............................. 182
ROM_id - gets the ROM id byte ................................ 183
round - round a real to a decimal place ...................... 184
rtrim - trims trailing blanks ................................ 185
scrbuff - calculate size of screen buffer .................... 186
scroll_down - scroll window down ............................. 187
scroll_up - scroll window up ................................. 188
ScrollLock - set the Scroll Lock key state ................... 189
set_color - set the default attribute (color) ................ 190
set_cursor - sets cursor scan lines .......................... 191
set_handles - set handle count ............................... 192
set_mode - set the video mode ................................ 193
setBREAK - set Ctrl-BREAK flag ............................... 194
setcursor - sets cursor scan lines ........................... 195
settextinfo - set text mode video information ................ 196
setVERIFY - set VERIFY flag .................................. 197
shorttoddate - convert a short date to struct ................ 198
sqr - square of a value ...................................... 199
stddev - calculate the standard deviation of a ............... 200
straight_line_dep - calculate straight line .................. 201
strcapital - capitalizes the first letter of each ............ 202
strclean - remove non-printable ASCII codes .................. 203
strcomma - convert a string to xx,xxx,xxx format ............. 204
strdel - delete part of a string ............................. 205
strfill - fill a string with a character ..................... 206
strins - insert one string into another ...................... 207
stroccur - count the occurences of a substring ............... 208
strrep - replicate a char .................................... 209
strshleft - shift string left ................................ 210
strshright - shift string right .............................. 211
strtocomma - convert a string to xx,xxx format ............... 212
strtoddate - convert a date string to a structure ............ 213
strtodol - converts a string to dollar format ................ 214
TCHK 2.0 Page 5
strtotime - convert a string to a time structure ............. 215
strwcmp - compares a wild-carded string to ................... 216
strwicmp - compares a wild-carded string to .................. 217
sum_year_digits_dep - calculate sum of the years ............. 218
summation - calculate a summation of integers ................ 219
swap - swap two values ....................................... 220
time_convert - convert time formats .......................... 221
timetostr - convert time structure to a string ............... 222
tocapkey - convert the key code to uppercase ................. 223
to24hour - converts hours to 24-hour format .................. 224
todosdate - make a DOS file date stamp ....................... 225
todostime - make a DOS file time stamp ....................... 226
tohour - converts 24-hour format to 12-hour .................. 227
valid_date - check if a date is valid ........................ 228
variance - calculate the variance of a set of ................ 229
vert_line - draw a vertical line ............................. 230
whereh - X-coordinate of cursor ............................. 231
wherev - Y-coordinate of cursor ............................. 232
#DEFINES .......................................................... 233
Ansihk.h ..................................................... 233
Color.h ...................................................... 233
Chiphk.h ..................................................... 233
Datehk.h ..................................................... 233
Doshk.h ...................................................... 234
Filehk.h ..................................................... 234
Finance.h .................................................... 235
Howard.h ..................................................... 235
Ibm.h ........................................................ 235
Keyboard.h ................................................... 236
Keycode.h .................................................... 236
Math.h ....................................................... 236
Menuhk.h ..................................................... 237
Multihk.h .................................................... 239
Printhk.h .................................................... 239
Video.h ...................................................... 239
VARIABLE TYPES .................................................... 239
GLOBAL VARIABLES .................................................. 240
Date variables: .............................................. 240
Keyboard variables: .......................................... 240
Multitasking variables: ...................................... 240
TCHK version variables: ...................................... 241
Video variables: ............................................. 241
REVISION HISTORY .................................................. 242
FUTURE ENHANCEMENTS ............................................... 245
OTHER PRODUCTS .................................................... 246
SUPPORT ........................................................... 246
TCHK 2.0 Page 6
APPENDIX A - DATE FORMATS ......................................... 248
APPENDIX B - date_convert() FORMATS ............................... 249
APPENDIX C - time_convert() FORMATS ............................... 251
TCHK 2.0 Page 7
COPYRIGHT AND DISCLAIMER
This library and documentation are Copyrighted (C) 1987, 1988 by
Howard Kapustein, All Rights Reserved.
Use of this library acknowledges this disclaimer of warranty:
"This library is supplied as-is. The author disclaims all
warranties, expressed or implied, including, without limitation,
the warranties of merchantability and of fitness of this library
for any purpose. The author assumes no liability for damages
direct or consequential, which may result from the use of this
library."
TRADEMARKS
Macintosh is a registered trademark of Apple Incorporated.
dBase III+ is a registered trademark of Ashton-Tate Incorporated.
TLIB, Turbo C and Turbo Assembler are registered trademarks
of Borland International.
Symphony is a registered trademark of Lotus Corp.
DESQview is a registered trademark of Quarterdeck Office Systems.
LICENSE
TCHK is NOT public domain or free software, but is being
distributed as "shareware" or "user supported" software, as
outlined below.
Non-registered users are granted a limited license to make an
evaluation copy for trial use on a private, non-commercial basis,
for the express purpose of determining whether TCHK is suitable
for their needs. At the end of this period you should either
register your copy or discontinue using TCHK as well as products
designed with unregistered versions of TCHK.
In english for those of you without law degrees, if you use TCHK
in developing some program you should pay for your copy of TCHK.
This way I'll be able to provide you with support, updates and
still feed myself.
Users may become REGISTERED owners for the small pittance of $15.
Registering has the following benefits:
Registered owners will receive TCHK compiled for use with all
memory models (not just the small memory model distributed
here.)
TCHK 2.0 Page 8
Registered owners are entitled to utilize TCHK in commercial
applications.
Registered owners will receive disk documentation and
libraries compiled for all memory models up to, and
including, the next non-trivial version increase (i.e. if you
register for 2.01, you will receive all versions from 2.01 to
2.1. If versions 2.01, 2.02 and 3.0 are released, you will
receive 2.01, 2.02 and 3.0).
REGISTERED owners may purchase the source code to TCHK for $35.
Businesses using TCHK, for whatever reason, MUST register.
Distribution of a program incorporating an unregistered version of
TCHK, in part or whole, is a violation of the law.
All users are granted a limited license to copy TCHK only for the
trial use of others and subject to the above limitations. This
license does NOT include distribution or copying of this software
package:
1 - In connection with any other product or service.
2 - For general use within a company or institution.
3 - For any consideration or 'disk fee'.
4 - In modified form, i.e. the file containing this license
information MUST be included, along with the full TCHK
documentation.
Operators of electronic bulletin board systems (Sysops) are
encouraged to post TCHK for downloading by their users, as long as
the above considerations are met.
If you are a distributor of a public domain or user-supported
software library, you may be eligible to distribute copies of
TCHK. You must meet all of the above conditions and acquire
written permission from me, the author (Howard Kapustein) before
doing so. Such permission is usually granted. Please call or write
for details.
BACKGROUND
I am a senior at Rensselaer Polytechnic Institute majoring in
computer science. I also do consulting/programming work as a
sideline (hint hint.) When I purchased Turbo C (way back at
version 1.0), I wanted to do more than bare bones printf(). I was
also engaged in designing some software requiring the use of
dates, and some other unusual functions. Thus, after several
months of testing and use, I developed a rather useful collection
of functions. After some requests from other programmers, I
decided to bundle most of them together and <gasp> document them.
Since then, my library has grown, and so has TCHK. This library is
a collection of most of these functions.
TCHK 2.0 Page 9
FILES
You may not distribute TCHK except in unmodified form, and it must
be distributed with all the following files:
READ.ME - last minute notes
TCHK.DOC - TCHK documentation
TCHK.REG - TCHK registration form
TCHK.TC - Turbo C configuration file
TCHKS.LIB - small memory model library
ANSIHK.H - header file for ANSI functions
CHIPHK.H - header file for chip id routines
COLOR.H - color definitions
DATEADV.H - header file for advanced date routines
DATECONV.H - header file for date conversion routines
DATEHK.H - header file for date routines
DOSHK.H - header file for DOS routines
FILEHK.H - header file for file routines
FINANCE.H - header file for financial routines
IBM.H - header file for misc. IBM routines
KEYBOARD.H - header file for keyboard routines
KEYCODE.H - keyboard key codes
MATHHK.H - header file of math routines
MENUHK.H - header file for menu routines
MULTIHK.H - header file for multi-tasking routines
PRINTHK.H - header file for print routines
STRINGHK.H - header file for string routines
TIMEHK.H - header file for time routines
VIDEO.H - header file for video routines
DEMO.ARC - archive of TCHK demo programs:
DEMOADV.C - date conversion functions
DEMOADV.PRJ
DEMODATE.C - date functions
DEMODATE.PRJ
DEMODISK.C - disktype function
DEMODISK.PRJ
DEMOLITE.C - litebar menu functions
DEMOLITE.PRJ
DEMOLOT.C - lotus menu functions (see Revisions)
DEMOLOT.PRJ
DEMONUM.C - number functions (math/financial)
DEMONUM.PRJ
DEMOPARS.C - DOS parsing functions
DEMOPARS.PRJ
DEMOPOP.C - popup menu functions
DEMOPOP.PRJ
DEMOTIME.C - time conversion functions
DEMOTIME.PRJ
TCHK 2.0 Page 10
To compile the demo programs, use the configuration file TCHK.TC
and the appropriate project file. Make sure you check the Turbo C
directories before compiling.
IN THE BEGINNING...
Except where explicitly stated, all of these functions have been
compiled and tested on my system:
- IBM PC
- 640K memory
- (CGA) Color Graphics Adapter
- DOS 3.2
- IBM Proprinter XL
- NEC V20 cpu
- PC Sprint (dandy little speed up plug in. No slot,
hardware switch for normal (4.77) and fast (~7) MHz speeds
and reboot. Between the board and the NEC my machine plods
along almost 2x as fast as a normal PC. At only $95, I
highly recommend it. Call these guys for more info:
Product: PC Sprint and/or NEC V20
Exec-PC, Inc.
PO BOX 11268
Shorewood, WI 53211
VOICE: (414) 963-2880
MODEM: (414) 964-5160
TCHK was compiled from the interactive environment of Turbo C,
with the following options changed from the default:
Memory model: SMALL
Optimize on: SPEED
Full optimization (Register/Jump)
No debug information
Standard stack frame Off
For more info, check out the configuration file TCHK.TC.
This library was written in 100% Turbo C, except for a couple of
TASM modules which were originally inline Assembly. All C code was
compiled with Turbo C 2.0, all Assembly was compiled with Turbo
Assembler 1.0 and TCHK created with TLIB 2.0.
TCHK 2.0 Page 11
FEATURES
TCHK sports many useful features not found in other shareware
packages. Aside from many input and output routines, TCHK is the
only package I have seen (and I've looked) that supplies date and
time functions. Also unique to TCHK is the Lotus style slash-bar,
popup and litebar menu functions.
Many of the functions requiring output as a side effect (most
noticeably the keyboard functions) make use of some of the output
routines prototyped in VIDEO.H or some of the console i/o
functions by Borland (i.e. cputs(), putch(), etc.). If you use
almost any of the keyboard routines, alse expect some video
routines to be linked into your program. This is true of some
other functions as well (the popup menus use Borland's gettext()
and cputs() routines.) If you really want to change the library,
you can always purchase the source code...
CREDIT
The following people deserve credit for their help:
James Arnold for helping with optimizing the direct video access
functions.
Darius Thabit for his help with the reboot function.
Mark Seyden, Sysop of The BOSS (201-568-7293), for allowing me
to use his bbs as a base for TCHK.
Robert Blacher, Sysop of Computer Connections (202-547-2008),
for his comments regarding my license information.
FUNCTIONS
Most of the functions are documented well enough below, although I
feel a few more explanations are necessary:
In the interactive environment you can #define one item in
terms of another, including spaces. If anyone knows how to do
this with the command line version, please let me know. The
variable type byte is just an unsigned char. If you use the
command line version of TC you will have to change the header
files of TCHK.
Beginning with TCHK 2.0, unless otherwise noted, all
functions asking for screen coordinates comply with Borland's
format (x,y). The top left corner of the screen is (1,1).
This is highly different from previous versions of TCHK.
Most functions rely on interrupts and low memory addresses
(400:xxxx) to comply with the IBM standard. Certain values
(for instance, the current video page) can be found by an
TCHK 2.0 Page 12
interrupt or by peeking at the value stored in low memory.
Many of the video functions especially require these values
to be found at the proper places. If your clone is radically
different from the IBM standard some of these functions may
not work properly. I didn't want to have to write a million
small functions that are just background support for the
functions found here (like current page number, etc.) so I
used the #defines found in the headers (see video.h for more
details.)
TCHK considers "key codes", "scan codes" and "ascii codes" as
different animals. Via the BIOS, any key pressed returns a
value. If a 'normal' key is pressed (i.e. a letter, space,
etc.) the low order byte contains the letter. When the low
order byte is zero, an unusual key has been pressed (i.e. Alt
combinations, arrows, grey +, etc.) This 2 byte word as
returned by the BIOS is called a scan code. For ease of use,
several functions convert this "scan code" to a value from
0-511, called a "key code", where 0-255 are 'normal' ascii
codes, as per the IBM ASCII character set, and 256-511 are
the unusual keys. Many of the popular key codes are listed in
KEYCODE.H. To determine a key code, if the low order byte is
zero, take the high order byte as a number 0-255 and add 256.
If the low order byte is non-zero, take the low order byte as
a number from 0-255. Note that although the regular plus key
and the grey plus key (on the numeric keypad) return
different scan codes, their key code is the same. So,
briefly, an "ascii code" is a char (value of 0-255), a "scan
code" is a 2-byte word returned from the BIOS, and a "key
code" is a value 0-511. "Scan codes" and "key codes" are both
2 bytes long (unsigned int and int, respectively).
There are several functions that refer to a DOS file name. A
'file name' is a generic term for any possible name for a
file (drive, path and even filename.ext are optional). A
'filename' refers to a DOS filename.ext, no drive or path
(sometimes referred to with 'filename.ext'). A 'filepathname'
refers to a full file name, including drive, path and
filename.ext (some parts may be optional.) A 'filespec' is
similiar to a 'filename', but does not necessarily refer to a
specific file (i.e. D:\TURBOC is actually D:\TURBOC\*.*. See
how DIR parses filespecs for more details.)
TCHK has not been tested on a Hercules or MDA video card
since I do not have access to either piece of hardware,
although the methods I used are well documented and should
cause no problems.
All functions that use my direct screen access routines have
built-in snow control. On CGA monitors, the snow was
horrendous without it. Unless I code these routines in
assembler, I won't be able to squeeze any more optimization
out of these routines. Since Borland now provides acceptable
console i/o functions, I doubt I shall bother to recode these
in Assembler.
TCHK 2.0 Page 13
One type of command you will NOT find in TCHK are windowing
commands. There are plenty of windowing libraries available. You
should not try to make your poor IBM into a Mac, it won't cut it.
Splurge for the Mac, you'll be happier. If you really want windows
on your IBM-type machine, use DESQview. Yes, I know, the
'windowing' interface is nicer. I use 'windows' too, although mine
are just boxes. I find it more than suitable for my current needs.
The functions are listed in the same manner as the Turbo C manual,
in alphabetical order.
TCHK 2.0 Page 14
Function accum_dep - calculate accumulated depreciation
Syntax double accum_dep(double cost, double salvage, int
life, int period, int dtype);
Prototype in finance.h
Remarks given the cost, salvage value and life of an item,
accum_dep will calculate the amount of accumulated
depreciation for the given period according to the
depreciation method specified by dtype. The cost
and salvage can be given in any unit (dollars,
thousands of dollars, etc.) but the life should be
given in depreciable periods (if you depreciate an
item every quarter, and the item has a life of 2
years, then life should be 8).
The cost and salvage values should be in the same
units. The life and period should be given in the
same units.
Types of depreciation supported by the variable
dtype are:
1 - Straight line depreciation
2 - Sum of the years digits depreciation
3 - Double declining balance depreciation
Any other value for dtype will produce
unpredictable results.
No error checking is performed.
This is a generic function to calculate the
accumulated depreciation given all necessary
information. Any unnecessary information is ignored
(i.e. double declining balance does not need a
salvage value.)
Return value returns the amount of depreciation for the given
period in the same units as the cost, as per the
depreciation method specified by dtype.
Note The macros ACC_DDB(c,l,p), ACC_SLD(c,s,l) and
ACC_SYD(c,s,l,p) are defined in finance.h for ease
of use.
See also accum_dep(), double_decline_bal_dep(),
straight_line_dep(), sum_year_digits_dep()
Example see demonum.c
TCHK 2.0 Page 15
Function ansi_call - create an ANSI escape sequence
Syntax char *ansi_call(int subfunction, int parm1, int
parm2, char *ansistring);
Prototype in ansihk.h
Remarks ansi_call is a general function that will create an
ANSI escape sequence for the given subfunction:
1: gotoxy(parm1,parm2)
2: cursor_right
3: cursor_left
4: cursor_up
5: cursor_down
6: save_cursor_position
7: restore_cursor_position
8: cls()
9: clear_eol()
10: set_foreground(parm1)
11: set_background(parm1)
12: clear_attributes (plain, normal)
13: bold
14: faint
15: italic
16: blink
17: fast_blink
18: inverse
19: invisible
20: set_mode(parm1)
21: reset_mode(parm1)
22: wherexy()
1: moves cursor to (parm1,parm2)
2-5: move cursor 1 space in direction indicated
6-7: save cursor position for future restoring
8: clear screen
9: clear to the end of current line
10-11: set colors for output
12-15,18-19: set attributes for output
16-17: control cursor blink rate
20-21: change mode (not same as DOS, see ansihk.h)
22: outputs the current cursor location
A value must be passed for parm1 and parm2, even if
they are not going to be used.
The escape sequence ansistring can be outputted
with a simple printf().
Remember, ANSI.SYS, FANSI-CONSOLE, or some similar
ANSI control sequence program must be active for
these codes to take effect.
TCHK 2.0 Page 16
Return value returns ansistring.
Note The color codes needed by ANSI functions are NOT
the same as the color codes used by DOS to set
attributes. Use the ANSI color #defines given in
ansihk.h.
See also ansiback(), ansifore()
TCHK 2.0 Page 17
Function ansiback - convert DOS background code to ANSI
Syntax int ansiback(char code);
Prototype in ansihk.h
Remarks DOS and ANSI use different values for colors. This
function converts a DOS background color code to
the ANSI color code for the same color.
Return value returns the ANSI background color code
See also ansi_call(), ansifore()
TCHK 2.0 Page 18
Function ansifore - convert DOS foreground code to ANSI
Syntax int ansifore(char code);
Prototype in ansihk.h
Remarks DOS and ANSI use different values for colors. This
function converts a DOS foreground color code to
the ANSI color code for the same color.
Return value returns the ANSI foreground color code
See also ansi_call(), ansiback()
TCHK 2.0 Page 19
Function atrim - trims leading and trailing blanks
Syntax char *atrim(char *source);
Prototype in stringhk.h
Remarks remove leading and trailing blanks in a string. The
string passed to atrim (source) is modified.
Return value returns a pointer to source.
Example #include <stringhk.h>
#include <stdio.h> /* for the printf */
main()
{
char msg[25] = " Hello everyone ";
printf("String [%s]\n",msg);
printf("atrim [%s]\n",atrim(msg));
}
Program output String [ Hello everyone ]
atrim [Hello everyone]
TCHK 2.0 Page 20
Function average - calculate the average of a set of reals
Syntax double average(int n, double element[]);
Prototype in mathhk.h
Remarks average calculates the average of a set of n
numbers of type double.
Return value returns the average of a set of n numbers.
See also stddev(), summation(), variance()
Example #include <mathhk.h>
main()
{
double num[] = { 2.3, 7.1, 6.05 };
printf("Average is %lf\n",average(3,num));
}
Program output Average is 5.15
TCHK 2.0 Page 21
Function beep - generate a standard IBM PC beep
Syntax void beep(void);
Prototype in ibm.h
Remarks makes the speaker beep (just like the beep during
bootup).
Return value nothing.
TCHK 2.0 Page 22
Function box - draw a box
Syntax int box(int left, int top, int right, int bottom,
char frame[]);
Prototype in video.h
Remarks draws a box via gotohv(), horiz_line(), putk() and
vert_line() (all use INTerrupts). Also, frame must
be have at least 9 elements (char frame[9]). The
box characters are frame[0] (top left) to frame[7]
(left wall), going clockwise. If frame[8] != '\0'
the box is filled with it.
Return value returns zero upon succesful completion, -1 if the
coordinates given are not large enough for a box.
See also global variables
boxwindow(), gotohv(), horiz_line(), putk(),
vert_line()
Example #include <video.h>
main()
{
char framebox[9] = "abcdefghi";
box(1,1,7,4,framebox);
}
Program output abbbbbc
hiiiiid
hiiiiid
gfffffe
TCHK 2.0 Page 23
Function boxwindow - draw a 'window'
Syntax int boxwindow(int left, int top, int right, int
bottom, char frame[], char *title,
int titlejustify, char colborder,
char coltitle, char colnorm, char
*buffer);
Prototype in video.h
Remarks draws a 'window'-like box (similiar to box(), but
with a title) at the coordinates (left,top) to
(right,bottom). The characters in frame[] are used
to generate the frame, with frame[9] and frame[10]
used as pre-/post-title separators. The title is
aligned as per titlejustify (LEFT, CENTER or RIGHT.
See HOWARD.H for more details). The frame uses the
colborder attribute, the title uses the coltitle
attribute and the inner portions of the box are
filled with spaces of colnorm color. The box is
stored in the memory allocated by buffer and
displayed with puttext().
The title is separated from the pre-/post-title
separators by a space.
Sufficient memory must be allocated for buffer to
contain the entire box, with attributes (see
scrbuff()).
Upon completion, buffer contains a copy of the
screen image of the box displayed (usable by
puttext()).
This routine is taken from an older version of the
popup...() and litebar...() creation functions.
This function does virtually no error checking and
does not currently support the NONE title
justification like the menu functions do.
Return value returns zero upon succesful completion, -1 if an
error occurs.
See also global variables
box(), horiz_line(), litebar...(), popup...(),
vert_line()
Example #include <video.h>
#include <howard.h> /* for CENTER */
#include <color.h> /* for colors */
main()
{
TCHK 2.0 Page 24
char vidbuff[scrbuff(1,1,15,4)],
framebox[] = "abcdefgh[]";
boxwindow(1,1,9,5,framebox,"Title",CENTER,
CYAN,YELLOW,RED,vidbuff);
}
Program output abb[ Title ]bbc
h d
h d
gfffffffffffffe
TCHK 2.0 Page 25
Function Cal... - family of Calendar date conversions
Syntax char *CaltoGreg(double cal);
char *CaltoGregEuro(double cal);
char *CaltoGregJap(double cal);
double CaltoJul(double cal);
double CaltoJulA(double cal);
double CaltoJulB(double cal);
double CaltoCalCent(double cal);
double CalCenttoCal(double cal);
Prototype in datehk.h
Remarks CaltoGreg converts Calendar date to Gregorian
(US) date
CaltoGregEuro converts Calendar date to Gregorian
(European) date
CaltoGregJap converts Calendar date to Gregorian
(Japan) date
CaltoJul converts Calendar date to Julian
(Type E) date
CaltoJulA converts Calendar date to Julian
(Type A) date
CaltoJulB converts Calendar date to Julian
(Type B) date
CaltoCalCent converts Calendar date to Calendar
date (w/century)
CalCenttoCal converts Calendar date (w/century)
to Calendar date
Return value CaltoGreg... return the appropriate Gregorian date
CaltoJul... return the appropriate Julian date
CaltoCalCent returns a Calendar date (w/century)
CalCentotCal returns a Calendar date
See also Appendix A
date_convert(), ddatetofull(), ddatetoshort(),
ddatetostr(), fulltoddate(), Greg...(), Jul...(),
monthexpand(), shorttoddate(), strtoddate()
Example see demodate.c
TCHK 2.0 Page 26
Function CapsLock - set the Caps Lock key state
Syntax void InsLock(boolean on);
Prototype in ibm.h
Remarks sets the Caps Lock key state to the state selected
by the on parameter.
Return value nothing.
See also InsLock(), NumLock(), ScrollLock()
TCHK 2.0 Page 27
Function changelitebar - set internal litebar menu
information
Syntax void changelitebar(struct litebar_header *lh,
struct litebar_field *lf)
Prototype in menuhk.h
Remarks sets internal variables for a litebar menu
regarding the currently hilited item.
This function is used internally by several
litebar...() menu functions.
Return value nothing.
Note This function is for internal uses only.
See also menuhk.h
litebar_alloc(), litebar_free(), litebar_get(),
litehilite(), litemessage(), liteunhilite()
litebarerrno
TCHK 2.0 Page 28
Function clear - clears a portion of the screen
Syntax void clear(int left, int top, int right,
int bottom);
Prototype in video.h
Remarks clears a box of the screen via gotohv() and putk().
All screen coordinates are absolute.
Return value nothing.
See also cls(), gotohv(), putk()
Example #include <video.h>
main()
{
clear(0,0,79,3); /* clear top 4 lines */
}
TCHK 2.0 Page 29
Function clear_typeahead - clear typeahead buffer
Syntax int clear_typeahead(void);
Prototype in keyboard.h
Remarks clears the typeahead buffer and returns the number
of keystrokes cleared
Return value number of keystrokes emptied from the typeahead
buffer
Example #include <keyboard.h>
#include <stdio.h>
main()
{
printf("# keystrokes emptied = %d",
clear_typeahead());
}
TCHK 2.0 Page 30
Function cls - clear screen
Syntax #include <video.h>
cls();
Prototype in video.h
Remarks clears screen by Borland's clrscr(). I hated their
name for it, so I #defined cls().
Return value nothing.
See also clear()
Example #include <video.h>
main()
{
cls()
}
TCHK 2.0 Page 31
Function color - make a single attribute
Syntax #include <video.h>
color(f,b)
Prototype in video.h
Remarks converts a color for a foreground and background
attribute in foreground format (0-15) to a single
byte.
This function is a macro.
Return value returns an attribute byte of foreground ORed with
the background shifted left 4 bits.
TCHK 2.0 Page 32
Function cpu_id - identify the cpu
Syntax int cpu_id(void);
Prototype in chiphk.h
Remarks cpu_id does some opcode magic to identify the cpu.
Currently identified chips are the 8088/8086,
80286, 80386 and the NEV V20/V30.
Return value returns a value identifying the cpu. See chiphk.h
for further details.
Note Other (not 88/86, 286, 386 or V20/V30) chips will
not be identified correctly, and will probably be
interpreted as an NEC cpu.
See also machine_id(), ndp_id()
TCHK 2.0 Page 33
Function cursor_blink - set speed of cursor blink
Syntax void cursor_blink(boolean fast);
Prototype in video.h
Remarks this function will make the cursor blink fast if
fast is TRUE, or slow if fast is FALSE.
Return value nothing.
See also cursor_flip(), cursor_off(), cursor_on(),
getcursor(), getcursor(), read_cursor(),
set_cursor(), setcursor()
TCHK 2.0 Page 34
Function cursor_flip - toggle the cursor type
Syntax void cursor_flip(unsigned int curs1,
unsigned int curs2);
Prototype in video.h
Remarks toggles the cursor scan lines to whichever set the
cursor is not currently set for.
Return value nothing.
See also cursor_blink(), cursor_off(), cursor_on(),
getcursor(), read_cursor(), set_cursor(),
setcursor()
Example #include <video.h>
main()
{
cursor_flip(CURSOR_UNDERBAR,CURSOR_HALFBLOCK);
}
TCHK 2.0 Page 35
Function cursor_off - turn the cursor off
Syntax void cursor_off(void);
Prototype in video.h
Remarks makes the cursor invisible.
Return value nothing.
See also cursor_blink(), cursor_flip(), cursor_on(),
getcursor(), read_cursor(), set_cursor(),
setcursor()
TCHK 2.0 Page 36
Function cursor_on - turn the cursor on
Syntax void cursor_on(void);
Prototype in video.h
Remarks makes the cursor visible.
Return value nothing.
See also cursor_blink(), cursor_flip(), cursor_off(),
getcursor(), read_cursor(), set_cursor(),
setcursor()
TCHK 2.0 Page 37
Function date_convert - convert date formats
Syntax boolean date_convert(void *source, void *dest,
int stype, int dtype);
Prototype in dateadv.h
Remarks date_convert will convert a date from virtually any
date format to any other. The parameters *source
and *dest must be pointers pointing to a piece of
memory allocated as the proper data type. stype and
dtype determine the format of source and dest.
Due to the great number of formats supported, a
chart of valid date formats is provided in Appendix
B.
Limited error checking is done on passed data. If
an invalid date format is passed, unpredictable
results will occur.
Return value returns TRUE is the conversion was successful and
FALSE if the date could not be converted.
Note This function does NO function calls except for
isleapyear(). I've tried to optimize this function
as much as possible for speed, not size. If you
only need to convert between, say, Calendar and
Julian dates, you may be better off using the
functions listed in datehk.h.
See also Appendix A, B
Cal...(), ddatetofull(), ddatetoshort(),
ddatetostr(), fulltoddate(), Greg...(), Jul...(),
monthexpand(), shorttoddate(), strtoddate()
Example see demoadv.c
TCHK 2.0 Page 38
Function dayofweek - find the day of the week
Syntax int dayofweek(double jul);
Prototype in datehk.h
Remarks finds the day of the week for a given Julian
(Type E) date
Return value returns 0-6 (Sun...Sat)
See also Appendix A
datehk.h
Example see demodate.c
TCHK 2.0 Page 39
Function dayofyear - calculate the day of the year
Syntax int dayofyear(struct ddate *d);
Prototype in datehk.h
Remarks dayofyear calculate the day of the year given a
date. The day of the year will range from 1
(January 1) to 365 (Dec 31, no leap year) or 366
(Dec 31, leap year.)
dayofyear does no error checking on passed
parameters.
Return value returns a number from 1 to 365 (no leap year) or
366 (leap year.)
See also dayofweek(), daysleft(), diffddate()
Example #include <datehk.h>
main()
{
struct ddate today;
/* set today to Feb 3, 1987 */
printf("%d/%d = day %d\n", today.dmon,
today.dday, dayofyear(&today));
}
Program output 2/3 = day 34
TCHK 2.0 Page 40
Function daysleft - calculate the days left in the year
Syntax int daysleft(struct ddate *d);
Prototype in datehk.h
Remarks daysleft calculates how many more days are left in
the year. The days left will range from 0 (Dec 31)
to 364 (Jan 1, no leap year) or 365 (Jan 1, leap
year.)
daysleft does no error checking on passed
parameters.
Return value returns a number from 0 to 364 (no leap year) or
365 (leap year.)
See also dayofyear(), diffddate()
Example #include <datehk.h>
main()
{
struct ddate today;
/* set today to Nov 3, 1987 */
printf("%d/%d = %d days left\n", today.dmon,
today.dday, daysleft(&today));
}
Program output 11/3 = 58 days left
TCHK 2.0 Page 41
Function ddatetofull - convert a date to full string
Syntax char *ddatetofull(struct ddate *source);
Prototype in datehk.h
Remarks ddatetofull converts a date from the structure
format ddate to a string in the form
Month dd, Year where
Month = the name of the month ("November")
dd = the day (5, 12, etc.)
Year = the year + 1900
Return value returns a pointer to the storage location
containing the date in string format, or NULL if
space could not be allocated.
See also Cal...(), date_convert(), ddatetoshort(),
ddatetostr(), fulltoddate(), Greg...(), Jul...(),
monthexpand(), shorttoddate(), strtoddate()
Example #include <datehk.h>
main()
{
struct ddate today;
char *strtoday;
/* assign some value to today */
strtoday = ddatetofull(&today);
printf("today is %d-%d-%d\n", today.dmon,
today.dday, today.dyear);
printf("or %s\n", (strtoday==NULL) ?
"no memory" : strtoday);
}
TCHK 2.0 Page 42
Function ddatetoshort - convert a date to short string
Syntax char *ddatetoshort(struct ddate *source);
Prototype in datehk.h
Remarks ddatetoshort converts a date from the structure
format ddate to a string in the form
Mon dd, Year where
Mon = the abbreviation of the month ("Nov")
dd = the day (5, 12, etc.)
Year = the year + 1900
Return value returns a pointer to the storage location
containing the date in string format, or NULL if
space could not be allocated.
See also Cal...(), date_convert(), ddatetofull(),
ddatetostr(), fulltoddate(), Greg...(), Jul...(),
monthexpand(), shorttoddate(), strtoddate()
Example #include <datehk.h>
main()
{
struct ddate today;
char *strtoday;
/* assign some value to today */
strtoday = ddatetoshort(&today);
printf("today is %d-%d-%d\n", today.dmon,
today.dday, today.dyear);
printf("or %s\n", (strtoday==NULL) ?
"no memory" : strtoday);
}
TCHK 2.0 Page 43
Function ddatetostr - convert a date to abbrev. string
Syntax char *ddatetostr(struct ddate *source);
Prototype in datehk.h
Remarks ddatetostr converts a date from the structure
format ddate to a string in the form mm-dd-y..y
where the month and day are always 2 digits long (a
0 is prefixed to single digit months and days) and
year is not altered.
Return value returns a pointer to the storage location
containing the date in string format, or NULL if
space could not be allocated.
See also Cal...(), date_convert(), ddatetofull(),
ddatetoshort(), ddatetostr(), fulltoddate(),
Greg...(), Jul...(), monthexpand(), shorttoddate(),
strtoddate()
Example #include <datehk.h>
main()
{
struct ddate today;
char *strtoday;
/* assign some value to today */
strtoday = ddatetostr(&today);
printf("today is %d-%d-%d\n", today.dmon,
today.dday, today.dyear);
printf("or %s\n", (strtoday==NULL) ?
"no memory" : strtoday);
}
TCHK 2.0 Page 44
Function depreciation - calculate depreciation for a
period
Syntax double depreciation(double cost, double salvage,
int life, int period, int
dtype);
Prototype in finance.h
Remarks given the cost, salvage value and life of an item,
depreciation will calculate the amount of
deprecitation for the given period according to the
depreciation method specified by dtype. The cost
and salvage can be given in any unit (dollars,
thousands of dollars, etc.) but the life should be
given in depreciable periods (if you depreciate an
item every quarter, and the item has a life of 2
years, then life should be 8).
The cost and salvage values should be in the same
units. The life and period should be given in the
same units.
Types of depreciation supported by the variable
dtype are:
1 - Straight line depreciation
2 - Sum of the years digits depreciation
3 - Double declining balance depreciation
Any other value for dtype will produce
unpredictable results.
No error checking is performed.
This is a generic function to calculate the
depreciation given all necessary information. Any
unnecessary information is ignored (i.e. straight
line depreciation does not need a period.)
Return value returns the amount of depreciation for the given
period in the same units as the cost, as per the
depreciation method specified by dtype.
See also accum_dep(), double_decline_bal_dep(),
straight_line_dep(), sum_year_digits_dep()
Example see demonum.c
TCHK 2.0 Page 45
Function DESQcommonmem - returns measure of common memory
available
Syntax void DESQcommonmem(struct DESQmemory *dm);
Prototype in multihk.h
Remarks determines the amount of available common memory
under DESQview. No error checking is performed.
DESQcommonmem returns the amount of available
common memory in dm. The values returned are in
bytes.
Return value nothing.
See also DESQconvenmem(), DESQdispchar(), DESQexit(),
DESQexpandedmem(), DESQfreeCPU(),
DESQInternalStack(), DESQMakeTone(),
DESQProgramStack(), DESQversion()
TCHK 2.0 Page 46
Function DESQconvenmem - returns measure of conventional
memory available
Syntax void DESQconvenmem(struct DESQmemory *dm);
Prototype in multihk.h
Remarks determines the amount of available conventional
memory under DESQview. No error checking is
performed.
DESQconvenmem returns the amount of available
conventional memory in dm. The values returned are
in Kbytes.
Return value nothing.
See also DESQcommonmem(), DESQdispchar(), DESQexit(),
DESQexpandedmem(), DESQfreeCPU(),
DESQInternalStack(), DESQMakeTone(),
DESQProgramStack(), DESQversion()
TCHK 2.0 Page 47
Function DESQdispchar - displays a char on the status line
Syntax char DESQdispchar(char c);
Prototype in multihk.h
Remarks displays a character on the status line. No error
checking is performed.
Return value DESQdispchar returns the .
See also DESQcommonmem(), DESQconvenmem(), DESQexit(),
DESQexpandedmem(), DESQfreeCPU(),
DESQInternalStack(), DESQMakeTone(),
DESQProgramStack(), DESQversion()
TCHK 2.0 Page 48
Function DESQexit - exit program in DESQview
Syntax void DESQexit(void);
Prototype in multihk.h
Remarks exits the current program under DESQview (and
possibly Topview). No error checking is performed.
Return value nothing.
See also DESQcommonmem(), DESQconvenmem(), DESQdispchar(),
DESQexpandedmem(), DESQfreeCPU(),
DESQInternalStack(), DESQMakeTone(),
DESQProgramStack(), DESQversion()
TCHK 2.0 Page 49
Function DESQexpandedmem - returns measure of expanded
memory available
Syntax void DESQexpanded(struct DESQmemory *dm);
Prototype in multihk.h
Remarks determines the amount of available expanded memory
under DESQview. No error checking is performed.
DESQexpandedmed returns the amount of available
expanded memory in dm. The values returned are in
Kbytes.
Return value nothing.
See also DESQcommonmem(), DESQconvenmem(), DESQdispchar(),
DESQexit(), DESQfreeCPU(), DESQInternalStack(),
DESQMakeTone(), DESQProgramStack(), DESQversion()
TCHK 2.0 Page 50
Function DESQfreeCPU - give up CPU time
Syntax void DESQfreeCPU(void);
Prototype in multihk.h
Remarks this function will free the remaining CPU cycles
under DESQview, Topview and Taskview. I have tested
this function only under DESQview, where I believe
it frees the reamining ticks in the program's turn.
If your program will just sit idle and chew up CPU
time, calling this function frees whatever remain
of its cpu share.
No error checking is performed.
Return value nothing.
See also DESQcommonmem(), DESQconvenmem(), DESQdispchar(),
DESQexit(), DESQexpandedmem(), DESQInternalStack(),
DESQMakeTone(), DESQProgramStack(), DESQversion()
Example ... /* code fragment */
while (bioskey(1) == 0) /* wait for keypress */
DESQfreeCPU(); /* w/o wasting cpu time */
...
TCHK 2.0 Page 51
Function DESQInternalStack - switch to DESQview's internal
stack
Syntax void DESQInternalStack(void);
Prototype in multihk.h
Remarks switches the stack used to DESQview's internal
stack. No error checking is performed.
Return value nothing.
See also DESQcommonmem(), DESQconvenmem(), DESQdispchar(),
DESQexit(), DESQexpandedmem(), DESQfreeCPU(),
DESQMakeTone(), DESQProgramStack(), DESQversion()
TCHK 2.0 Page 52
Function DESQMakeTone - makes a tone under DESQview
Syntax void DESQMakeTone(int frequency, int duration);
Prototype in multihk.h
Remarks DESQMakeTone will generate a tone of frequency in
Hz for duration clock ticks (approximately 18.2
ticks/sec). No error checking is performed.
Return value nothing.
See also DESQcommonmem(), DESQconvenmem(), DESQdispchar(),
DESQexit(), DESQexpandedmem(), DESQfreeCPU(),
DESQInternalStack(), DESQProgramStack(),
DESQversion()
TCHK 2.0 Page 53
Function DESQProgramStack - switch back to program's
stack
Syntax void DESQProgramStack(void);
Prototype in multihk.h
Remarks switches the stack from DESQview's internal stack
back to the program's stack. No error checking is
performed.
Return value nothing.
See also DESQcommonmem(), DESQconvenmem(), DESQdispchar(),
DESQexit(), DESQexpandedmem(), DESQfreeCPU(),
DESQInternalStack(), DESQMakeTone(), DESQversion()
TCHK 2.0 Page 54
Function DESQversion - DESQview version
Syntax int DESQversion(void);
Prototype in multihk.h
Remarks determines if DESQview is running and gets the
version number
Return value returns zero if DESQview is not running, otherwise
returns the version number with the major version
number in the high order byte and the minor version
number in the low order byte.
Note Now that I've gotten this function to work properly
for DESQview, I do not guarrantee it's accuracy
with regards to Topview or Taskview. If someone out
there with access to either could test it out and
let me know I'd appreciate it.
See also DESQcommonmem(), DESQconvenmem(), DESQdispchar(),
DESQexit(), DESQexpandedmem(), DESQfreeCPU(),
DESQInternalStack(), DESQMakeTone(),
DESQProgramStack()
Example #include <multihk.h>
main()
{
unsigned int ver;
if ((ver = DESQversion()) == 0)
printf("DESQview is not running\n");
else
printf("DESQview version %d.%2d\n",
(ver&0xFF00)>>8, ver&0x00FF);
}
TCHK 2.0 Page 55
Function diffddate - calculate the difference in 2 dates
Syntax long int diffddate(struct ddate *start,
struct ddate *fini);
Prototype in datehk.h
Remarks diffdate calculates the difference in days between
start and fini (fini - start).
diffdate does not perform any error checking on the
passed parameters.
Return value returns the number of days from start to fini.
See also dayofyear(), daysleft(), diffddate()
Example #include <datehk.h>
main()
{
struct ddate begin, end;
long int days;
/* set begin to Jan 1, 1981 */
/* set end to Feb 5, 1982 */
days = diffdate(&begin,&end);
printf("Feb 5, 1982 - Jan 1, 1981 =
%ld\n",days);
}
Program output Feb 5, 1982 - Jan 1, 1981 = 400
TCHK 2.0 Page 56
Function diskchanged - has the disk has been changed
Syntax boolean diskchanged(int drive);
Prototype in ibm.h
Remarks diskchanged determines if the disk has been changed
since the last access via INT 0x13, Function 0x16.
The drive parameter corresponds to the drive
letter, 0 = A:, 1 = B:, etc.
Return value returns TRUE if the disk has been changd since the
last access and FALSE otherwise.
Note This function valid only on AT, XT2, XT286,
Convertible and PS/2.
See also disktype()
TCHK 2.0 Page 57
Function disktype - identify disk type
Syntax byte disktype(byte drive);
Prototype in ibm.h
Remarks disktype will determine the type of disk in the
disk drive being tested. drive specifies the drive
to check. Set drive to zero to specify the default
drive, one is A:, two is B:, etc.
Return value returns the drive id byte. See ibm.h for more
details.
See also diskchanged()
Example see demodisk.c
TCHK 2.0 Page 58
Function dosday - extract day from file date stamp
Syntax #include <doshk.h>
(unsigned) dosday(d)
Prototype in doshk.h
Remarks extracts the day from a DOS file date stamp. Refer
to a DOS reference book (Advanced MS-DOS by Ray
Duncan recommended) for further details.
This function is a macro.
Return value returns the day of a DOS file date stamp.
See also doshour(), dosmonth(), dosmin(), dossec(),
dosyear(), todosdate(), todostime()
TCHK 2.0 Page 59
Function doshour - extract hour from file time stamp
Syntax #include <doshk.h>
(unsigned) doshour(h)
Prototype in doshk.h
Remarks extracts the hour from a DOS file time stamp. Refer
to a DOS reference book (Advanced MS-DOS by Ray
Duncan recommended) for further details.
This function is a macro.
Return value returns the hour of a DOS file time stamp.
See also dosday(), dosmonth(), dosmin(), dossec(),
dosyear(), todosdate(), todostime()
TCHK 2.0 Page 60
Function dosmonth - extract hour from file date stamp
Syntax #include <doshk.h>
(unsigned) dosmonth(m)
Prototype in doshk.h
Remarks extracts the month from a DOS file date stamp.
Refer to a DOS reference book (Advanced MS-DOS by
Ray Duncan recommended) for further details.
This function is a macro.
Return value returns the hour of a DOS file date stamp.
See also dosday(), doshour(), dosmin(), dossec(), dosyear(),
todosdate(), todostime()
TCHK 2.0 Page 61
Function dosmin - extract minutes from file time stamp
Syntax #include <doshk.h>
(unsigned) dosmin(m)
Prototype in doshk.h
Remarks extracts the minutes from a DOS file time stamp.
Refer to a DOS reference book (Advanced MS-DOS by
Ray Duncan recommended) for further details.
This function is a macro.
Return value returns the minutes of a DOS file time stamp.
See also dosday(), doshour(), dosmonth(), dossec(),
dosyear(), todosdate(), todostime()
TCHK 2.0 Page 62
Function dossec - extract seconds from file time stamp
Syntax #include <doshk.h>
(unsigned) dossec(s)
Prototype in doshk.h
Remarks extracts the seconds from a DOS file time stamp.
Refer to a DOS reference book (Advanced MS-DOS by
Ray Duncan recommended) for further details.
This function is a macro.
Return value returns the hour of a DOS file time stamp.
See also dosday(), doshour(), dosmonth(), dosmin(),
dosyear(), todosdate(), todostime()
TCHK 2.0 Page 63
Function dosyear - extract year from file date stamp
Syntax #include <doshk.h>
(unsigned) dosyear(y)
Prototype in doshk.h
Remarks extracts the year from a DOS file date stamp. Refer
to a DOS reference book (Advanced MS-DOS by Ray
Duncan recommended) for further details.
This function is a macro.
Return value returns the year of a DOS file date stamp.
See also dosday(), doshour(), dosmonth(), dosmin(),
dossec(), todosdate(), todostime()
TCHK 2.0 Page 64
Function double_decline_bal_dep - calculate double
declining balance
depreciation
Syntax double double_decline_bal_dep(double cost, int
life, int period);
Prototype in finance.h
Remarks given the cost and life of an item,
double_decline_bal_dep will calculate the amount of
deprecitation for the given period according to the
double declining balance depreciation method. The
cost can be given in any unit (dollars, thousands
of dollars, etc.) but the life should be given in
depreciable periods (if you depreciate an item
every quarter, and the item has a life of 2 years,
then life should be 8).
The life and period should be given in the same
units.
No error checking is performed.
Return value returns the amount of depreciation for the given
period in the same units as the cost, as per the
double declining balance depreciation method.
Note The macro DDB(c,l,p) is defined in finance.h for
ease of use.
See also accum_dep(), depreciation(), straight_line_dep(),
sum_year_digits_dep()
Example see demonum.c
TCHK 2.0 Page 65
Function DoubleDOSfreeCPU - give up CPU time under
Double DOS
Syntax void DoubleDOSfreeCPU(byte slices);
Prototype in multihk.h
Remarks DoubleDOSfreeCPU frees up CPU time from the current
program. The amount of time freed up is found by
slices * 55ms.
Return value nothing.
See also DoubleDOSGetVirtual(), DoubleDOSTaskSwitch(),
isDoubleDOS()
Example #include <multihk.h>
main()
{
DoubleDOSfreeCPU(1000); /* frees 55 secs */
}
TCHK 2.0 Page 66
Function DoubleDOSGetVirtual - get DoubleDOS virtual
screen address
Syntax unsigned int DoubleDOSGetVirtual(void);
Prototype in multihk.h
Remarks determines and returns the segment of the virtual
screen address for the current task.
Return value DoubleDOSGetVirtual returns the segment of the
virtual screen address
See also DoubleDOSfreeCPU(), DoubleDOSTaskSwitch(),
isDoubleDOS()
TCHK 2.0 Page 67
Function DoubleDOSTaskSwitch - set Double DOS task
switching on/off
Syntax void DoubleDOSTaskSwitch(boolean on);
Prototype in multihk.h
Remarks sets Double DOS task switching on or off.
Return value nothing.
See also DoubleDOSfreeCPU(), DoubleDOSGetVirtual(),
isDoubleDOS()
Example #include <multihk.h>
#define ENABLE TRUE
main()
{
DoubleDOSTaskSwitch(ENABLE);
}
TCHK 2.0 Page 68
Function EMMversion - version of Expanded Memory Manager
Syntax boolean EMMversion(byte *version);
Prototype in ibm.h
Remarks determines the version of the Expanded Memory
Manager. No memory is allocated.
Return value returns TRUE if successful (and *version is the
version id,) FALSE if an error occurred (and
*version is the error code.)
Note this function is available under EMM 3.2 specs.
See also ibm.h
getEMSstatus(), isEMSavail(), ESMinfo(),
EMSpages(), EMSwarmbootprep()
Example #include <ibm.h>
main()
{
byte ver;
if (isEMSavail())
if (EMMversion(&ver)) /* success */
printf("EMM version id %X\n",ver);
else /* error */
printf("EMM error code %X\n",ver);
}
TCHK 2.0 Page 69
Function EMSinfo - determines EMM version and EMS pages
Syntax boolean EMSinfo(struct EMSrecord *ems);
Prototype in ibm.h
Remarks if EMS is available, EMSinfo() determines the EMM
version number and the total and available pages.
This information is saved in the ems structure
passed to EMSinfo().
This function is similar to isEMSavail() and
EMSpages()
Return value returns TRUE if EMS is available and no errors were
encountered. On an error, FALSE is returned and
ems->emserror will contain the error code.
Note this function is available under EMM 3.2 specs.
See also ibm.h
EMMversion(), getEMSstatus(), isEMSavail(),
EMSpages(), EMSwarmbootprep()
Example #include <ibm.h>
main()
{
struct EMSrecord ems;
if (EMSinfo(&ems)) {
printf("EMM version id: %X\n",
ems.version);
printf("Total pages: %u\n",
ems.totalpages);
printf("Avail pages: %u\n",
ems.availpages);
} else /* error */
printf("EMM error code %X\n",
ems.emserror);
}
TCHK 2.0 Page 70
Function EMSpages - determines the total and available
amount of pages of EMS memory
Syntax boolean EMSpages(struct EMSrecord *ems);
Prototype in ibm.h
Remarks EMSpages() determines the total and available
amount of pages of EMS memory. This information is
saved in the ems structure passed to EMSpages().
Return value returns TRUE if no errors were encountered. On an
error, FALSE is returned and ems->emserror will
contain the error code.
Note this function is available under EMM 3.2 specs.
See also ibm.h
EMMversion(), getEMSstatus(), isEMSavail(),
ESMinfo(), EMSwarmbootprep()
TCHK 2.0 Page 71
Function EMSwarmbootprep - prepares the EMM for warm boot
Syntax int EMSwarmbootprep(void);
Prototype in ibm.h
Remarks EMSwarmbootprep tells the Expanded Memory Manager
to prepare for a warm boot.
Return value returns the EMM error code. If no errors occurred,
zero is returned. See ibm.h for a list of EMM error
codes.
Note this function is available under EMM 4.0 specs.
See also ibm.h
EMMversion(), getEMSstatus(), isEMSavail(),
ESMinfo(), EMSpages()
TCHK 2.0 Page 72
Function endstri - get offset to last char of a string
Syntax #include <stringhk.h>
(int) endstri(s)
Prototype in stringhk.h
Remarks gets an offset to the last character of a string.
This function is a macro. Strings of length 0 will
produce unpredictable results.
Return value returns an int offset to the last character in the
string s.
See also endstri()
TCHK 2.0 Page 73
Function endstrp - get pointer to last char of a string
Syntax #include <stringhk.h>
(char *) endstrp(s)
Prototype in stringhk.h
Remarks gets a pointer to the last character of a string.
This function is a macro. Strings of length 0 will
produce unpredictable results.
Return value returns a pointer to the last character in the
string s.
See also endstri()
TCHK 2.0 Page 74
Function expandfilespec - expand a filespec into a full
DOS filepathname
Syntax char *expandfilespec(char *filespec, char *dest);
Prototype in filehk.h
Remarks expandfilespec will take a DOS filespec (optional
drive, optional path, optional file name) and
expand it into a full filepathname, consisting of
drive, path and file name. Any information needed
to make a fully explicit filepathname
(d:\path\filename.exe) not provided by filespec
will be retrieved as the current drive and path,
with the filename.ext wildcarded appropriately.
dest must be a pointer to an allocated piece of
memory large enough to hold the full filepathname
(d:\path\filename.ext).
expandfilespec() relies on parsefilename() to break
s into its respective parts (drive, path and
filename.) Thus, any restrictions applying to
parsefilename() also apply to getfilespec().
Return value returns dest.
See also getfilespec(), isdir(), parsefilename(),
parsefnameext()
TCHK 2.0 Page 75
Function Extendedtotal - total Extended memory installed
Syntax int Extendedtotal(void);
Prototype in ibm.h
Remarks detects the total amount of Extended memory
installed.
Return value returns the total Extended memory installed, in
Kbytes.
Note you should check for the presence of Extended
memory with isExtended() before using this
function. Calling Extendedtotal() when no Extended
memory is present can lead to unpredictable
results.
See also isExtended()
Example #include <ibm.h>
main()
{
printf("Total Extended Memory is %dK\n",
Extendedtotal());
}
TCHK 2.0 Page 76
Function factorial - determines a factorial (n!)
Syntax double factorial(int n);
Prototype in mathhk.h
Remarks factorial returns n! (1*2*3*...*n). Traditionally
seen as a recursive function used to illustrate
recursion, factorial is done with a loop, using no
recursion.
Return value returns n factorial (n! = 1*2*3*...*n). If n <= 1,
factorial returns 1. If the result of n! is larger
than MAXDOUBLE (the largest value a double can
store, defined in Borland's LIMITS.H), factorial
return zero.
See also summation()
Example #include <mathhk.h>
main()
{
double f;
if ((f = factorial(13)) == 0)
printf("Error computing 13!\n");
else
printf("13! = %15.0lf\n",factorial(13));
}
Program output 13! = 6227020800
TCHK 2.0 Page 77
Function fname_match - compare filenames w/wildcards
Syntax int fname_match(char *fname1, char *fname2);
Prototype in filehk.h
Remarks compares filename fname1 to fname2 with wildcard
matching (*,?). Case is irrelevant.
Return value return a value
< 0 if fname1 is less than fname2
= 0 if fname1 is the same as fname2
> 0 if fname1 is greater than fname2
Note fname_match() compares strings just like DOS does
(or at least DOS 3.2, the one I work under.) Thus:
"STR*.*" = "str*.*"
"str.d*" = "StR.DZ"
"str" = "str.c"
Very little error checking is done. If an invalid
filename is passed (i.e. more than 12 characters
long) unpredictable results may occur.
See also fncmp()
Example #include <filehk.h>
main()
{
char a[12], b[12];
int cmp;
strcpy(a,"stringhk.c");
strcpy(b,"?TRI*");
printf("%s ",a);
if ((cmp = fname_match(a,b)) == 0)
printf("=");
else if (cmp < 0)
printf("<");
else
printf(">");
printf(" %s\n",b);
}
Program output stringhk.c = ?TRI*
TCHK 2.0 Page 78
Function fncmp - compare filenames w/wildcards
Syntax int fncmp(char *fname1, char *fname2);
Prototype in filehk.h
Remarks compares filename fname1 to fname2 with wildcard
matching (*,?). Case is irrelevant.
Return value return a value
< 0 if fname1 is less than fname2
= 0 if fname1 is the same as fname2
> 0 if fname1 is greater than fname2
In fact, if the value returned is 1 or -1, the
compare failed during the filename portion, and if
2 or -2 is returned, the compare failed during the
extension portion.
Note fncmp() compares strings just like DOS does (or at
least DOS 3.2, the one I work under.) Thus:
"STR*.*" = "str*.*"
"str.d*" = "StR.DZ"
"str" = "str.c"
Very little error checking is done. If an invalid
filename is passed (i.e. more than 12 characters
long) unpredictable results may occur.
See also fname_match()
Example #include <filehk.h>
main()
{
char a[12], b[12];
int cmp;
strcpy(a,"stringhk.c");
strcpy(b,"?TRI*.cc");
printf("%s ",a);
cmp = fncmp(a,b);
printf("Compare: %s %s Yields: %d\n",
a,b,cmp);
}
Program output Compare: stringhk.c ?TRI*.cc Yields: -2
TCHK 2.0 Page 79
Function frac - round the fractional portion of a real
Syntax double frac(double x);
Prototype in mathhk.h
Remarks frac will return the fractional portion of x.
Return value returns the fractional portion of x.
See also frac()
Example #include <mathhk.h>
main()
{
printf("frac(%lf) = %lf\n",-2.307,
frac(-2.307));
Program output frac(-2.307) = -0.307
Example see demonum.c
TCHK 2.0 Page 80
Function fsgn - sign of a real
Syntax #include <mathhk.h>
(int) fsgn(x)
Prototype in mathhk.h
Remarks fsgn will determine the sign of x. Zero is
considered positive.
This function is a macro.
The macro fsign() is defined as fsgn().
Return value returns -1 if x is negative, otherwise 1.
See also isgn(), lsgn()
TCHK 2.0 Page 81
Function fulltoddate - convert a full date to struct
Syntax struct ddate *fulltoddate(char *source);
Prototype in datehk.h
Remarks fulltoddate converts a date from a full date format
to the structure ddate format
Return value returns a pointer to the storage location
containing the date structure, or NULL if space
could not be allocated.
See also see Appendix A
Cal...(), date_convert(), ddatetofull(),
ddatetoshort(), ddatetostr(), Greg...(), Jul...(),
monthexpand(), shorttoddate(), strtoddate()
Example see demodate.c
TCHK 2.0 Page 82
Function FV - calculate the Future Value of a single
amount
Syntax double FV(double payment, double interest, int
periods)
Prototype in finance.h
Remarks FV calculates the Future Value of a single amount
given the present value of the principal, the
interest rate per period and the number of periods.
Return value returns the future value of a single amount.
See also FVa(), PMT(), PV(), PVa()
TCHK 2.0 Page 83
Function FVa - calculate the Future Value of an annuity
Syntax double FVa(double payment, double interest, int
periods)
Prototype in finance.h
Remarks FVa calculates the Future Value of an annuity given
the amount of each payment, the interest rate per
period and the number of periods.
Return value returns the future value of an annuity.
See also FV(), PMT(), PV(), PVa()
TCHK 2.0 Page 84
Function getBootBlock - get Boot Block
Syntax boolean getBootBlock(int drive, struct BootBlock
*BB)
Prototype in doshk.h
Remarks gets the Boot Block for the disk determined by
drive, where 0=A, 1=B, etc. BB must be a pointer to
an allocated piece of memory.
Return value returns TRUE if successful, otherwise returns FALSE
with the DOS error code in the global variable
errno.
See also getBPB()
Example #include <doshk.h>
main()
{
struct BootBlock BB;
if (getBootBlock(0,&BPB))
printf("Got it");
else
printf("Error");
}
TCHK 2.0 Page 85
Function getBPB - get Bios Parameter Block
Syntax boolean getBPB(int drive, struct BIOSParmBlock
*BPB);
Prototype in doshk.h
Remarks gets the Bios Parameter Block for the disk
determined by drive, where 0=A, 1=B, etc. BPB must
be a pointer to an allocated piece of memory.
Return value returns TRUE if successful, otherwise returns FALSE
with the DOS error code in the global variable
errno.
See also getBootBlock()
Example #include <doshk.h>
main()
{
struct BIOSParmBlock BPB;
if (getBPB(0,&BPB))
printf("Got it");
else
printf("Error");
}
TCHK 2.0 Page 86
Function getc_match - get specific input, case dependent
Syntax char getc_match(boolean output, char *match);
Prototype in keyboard.h
Remarks getc_match accepts character input (via getk())
until one of the characters in the string match in
entered, case dependent ('a' != 'A'). Extended keys
never match (F10 will never be a match.) If output
= TRUE, the character is echoed to the screen via
putk().
Return value returns the key pressed.
See also getc_match(), getk(), getlogical(), getyn()
Example #include <keyboard.h>
main()
{
printf("Enter your choice (abcdHJ): ");
getc_match(1,"abcdHJ");
}
Program output Enter your choice (abcdHJ): H
TCHK 2.0 Page 87
Function getci_match - get specific input, case
independent
Syntax char getci_match(boolean output, char *match);
Prototype in keyboard.h
Remarks getci_match accepts character input (via getk())
until one of the characters in the string match in
entered, case independent ('a' == 'A'). Extended
keys never match (F10 will never be a match.) If
output = TRUE, the character is echoed to the
screen via putch().
Return value returns the key pressed.
See also getc_match(), getk(), getlogical(), getyn()
Example #include <keyboard.h>
main()
{
printf("Enter your choice (Q, X, F, D): ");
getci_match(1,"QXFD");
}
Program output Enter your choice (Q, X, F, D): f
TCHK 2.0 Page 88
Function getcursor - gets cursor scan lines
Syntax unsigned int getcursor(void);
Prototype in video.h
Remarks gets the cursor scan lines via INT 0x10, Function
3.
Return value returns the scan lines of the cursor, with the
starting scan line in the high order byte and the
ending scan line in the low order byte.
See also cursor_blink(), cursor_flip(), cursor_off(),
cursor_on(), read_cursor(), set_cursor(),
setcursor()
TCHK 2.0 Page 89
Function getdatehk - inputs a date from the keyboard
Syntax char *getdatehk(void);
Prototype in keyboard.h
Remarks getdatehk inputs a date from the keyboard in the
form xx-xx-xx. Only digits, space and backspace are
valid input. Input is terminated when the ENTER key
is pressed. Video output is via Borland's console
i/o.
Return value if a valid date is entered, getdatehk returns a
string in the form xx-xx-xx, otherwise NULL is
returned.
Example #include <keyboard.h>
#include <stdio.h>
main()
{
char *c;
printf("What is today's date: ");
if ((c = getdatehk()) != NULL)
printf("Today is %s\n",c);
}
Program output What is today's date: 11-10-87
Today is 11-10-87
TCHK 2.0 Page 90
Function getdouble - inputs a double from the keyboard
Syntax char *getdouble(void);
Prototype in keyboard.h
Remarks getdouble inputs a double from the keyboard. Only
digits, decimal point, leading sign and backspace
are valid input. Input is terminated when the ENTER
key is pressed. Video output is via Borland's
console i/o.
The maximum length of input is 25.
Return value returns a string of the format [sn] [ddd] [.]
[ddd] where
[sn] = optional sign (+ or -)
[ddd] = optional digits
[.] = optional decimal point
See also getint(), getreal()
Example #include <keyboard.h>
#include <stdio.h>
main()
{
char *c;
printf("Give me a double: ");
c = getdouble();
printf("Your input is %s\n",c);
}
Program output Give me a double: -1289.12003
Your input is -1289.12003
TCHK 2.0 Page 91
Function getEMSstatus - get Expanded Memory status
Syntax byte getEMSstatus(void);
Prototype in ibm.h
Remarks getEMSstatus tests whether the expanded memory
hardware is functional. This function should only
be made after it has been established that EMS is
available and the EMM is ready (via isEMSavail()).
This is not a substitute to determine if EMS is
available.
Return value returns the EMM error code. If zero is returned,
the function is successful. If any other value is
returned, an error has occurred.
Note this function is available under EMM 3.2 specs.
See also ibm.h
EMMversion(), isEMSavail(), ESMinfo(), EMSpages(),
EMSwarmbootprep()
TCHK 2.0 Page 92
Function getfilespec - get a DIR proper filespec
Syntax char *getfilespec(char *s);
Prototype in filehk.h
Remarks getfilespec parses a string pointed to by s for a
file name. Any drive and path information is
stripped from the string and the filename.ext is
expanded with wildcards, as DIR does internally
(i.e. c:tchk.lib has a filename.ext of tchk.lib amd
c:tchk. has a filenameext of tchk., but c:tchk has
a filename.ext of tchk.*). The original string s is
modified.
getfilespec() relies on parsefilename() to strip
any drive and path information from s. Thus, any
restrictions applying to parsefilename() also apply
to getfilespec().
Return value returns a pointer to s.
See also parsefilename(), parsefnameext()
Example see demopars.c
TCHK 2.0 Page 93
Function getfname - get a filename from the keyboard
Syntax int getfname(byte row, byte col, char *returnstr,
char *pattern, int argn, int argk[],
char flags);
Prototype in video.h
Remarks getfname calls getget() asking for input of a
length 12 string, at the coordinates (col,row),
including pattern formatting and optional input
exit keys listed in argk. If memory was allocated
for returnstr, the string pointed to by returnstr
is checked to see if it is a valid DOS filename. A
valid filename must be of the form
[filename] [.] [ext] and does not contain
any of the following:
[ ] ; , . / ? * : " + = - < > \ |
If memory could not be allocated for the string,
returnstr will be set to NULL.
For more info on pattern and argk requirements,
check the stats for getget().
Return value if memory could not be allocated for returnstr or
the string pointed to by returnstr is not a valid
filename, -1 is returned, otherwise the key used to
exit the input is returned.
See also getget()
Example #include <filehk.h>
#include <keycode.h>
main()
{
char *fname;
int keys[2]={ESC,F10}; /* ESC & F10 exit
input */
gotoxy(0,0);
printf("Enter file: ");
if (getfname(0,13,fname,"!",2,keys) == -1)
printf(" BAD FILENAME");
else
printf(" valid filename");
}
Program output
TCHK 2.0 Page 94
Function getget - get a string from the keyboard w/editing
Syntax int getget(int col, int row, char *returnstr,
int size, char *pattern, int argn,
int argk[], char flags);
Prototype in keyboard.h
Remarks getget inputs a string at coordinates (col,row), of
maximum length size, formatted according to
pattern. Input ends when ENTER or one of the scan
codes specified in argk[] in inputted. There are
argn number of elements in argk[]. The string is
returned in returnstr and the function returns the
key code of the exiting key.
Full feature editing of the string includes:
Enter Ends input, exits function
Backspace normal backspace
Insert toggle inset/overwrite mode
Delete delete character under cursor
Left Arrow move cursor back 1 character
Right Arrow move cursor forward 1 character
Home move cursor to beginning of
string
End move cursor to end of string
Ctrl-Y delete entire string
Alt-Y delete string from cursor to
end
Ctrl-Right move cursor to beginning of
next word
Ctrl-Left move cursor to beginning of
previous word
Alt-U undo editing - restore initial
string
Here are the valid patterns:
pattern format
------- ------
Types a Alphabetic
A Alphabetic and capitalized
h Hexadecimal
H Hexadecimal and capitalized
n Alphanumeric
N Alphanumeric and capitalized
X Ascii (default)
9 Numeric
# Numeric and punctuation
Modifiers ! convert to upper case
. punctuation
TCHK 2.0 Page 95
( left justify
) right justify
^ center justify
The flags modifier is a bit field of flags, as
follows:
xxxxBLRI where
B = Bell
L = trim Left side on exit
R = trim Right side on exit
I = start edit in Insert mode (as
opposed to Overwrite mode)
Input is done via the inkey() function.
Video output is via Borland's console i/o.
Return value returns the key code of the key causing the exit
See also getstr()
TCHK 2.0 Page 96
Function getint - inputs an integer from the keyboard
Syntax char *getint(void);
Prototype in keyboard.h
Remarks getint inputs an integer from the keyboard. Only
digits, leading sign and backspace are valid input.
Input is terminated when the ENTER key is pressed.
the maximum length of input is 25.
Video output is via Borland's console i/o.
Return value returns a string of the format [sn] [ddd] where
[sn] = optional sign (+ or -)
[ddd] = optional digits
See also getdouble(), getreal()
Example #include <keyboard.h>
#include <stdio.h>
main()
{
char *c;
printf("Give me an integer: ");
c = getint();
printf("Your input is %s\n",c);
}
Program output Give me an integer: -1289
Your input is -1289
TCHK 2.0 Page 97
Function getk - get a key
Syntax byte getk(boolean wait);
Prototype in keyboard.h
Remarks getk returns the ascii code of the key pressed. If
no key was pressed (WAIT = FALSE) zero is returned.
This function is similar to getchar() except input
is not echoed to the screen and getk will detect
any key press (any standard keypress. It cannot
distinguish between the grey '+' key and the white
'+'. This function is interrupt driven. It will
detect ALT combinations, Del, PgUp, function keys,
etc., any keyboard INTerrupt accepted keys.)
Return value returns the ascii code for the key pressed, from 1
to 255. If WAIT = FALSE, and no key is pressed,
zero is returned. Check the global variables
key_status and key_extended to determine the shift
key status and if the key is an extended one.
See also keycode.h
getc_match(), getc_match(), getlogical(), getyn(),
inkey(), inkeyc()
Example #include <keyboard.h>
#include <stdio.h>
main()
{
extern boolean key_extended;
byte c;
c = getk(WAIT);
printf("Key code # in keycode.h: %d\n",
key_extended ? c+256 : c);
}
TCHK 2.0 Page 98
Function getlogical - get Yes/No
Syntax char getlogical(int output);
Prototype in keyboard.h
Remarks getlogical waits for a True/False key (TtFfYyNn) to
be pressed and then displays a message via putstr()
according to output:
output Message displayed
------ -----------------
0 no message
1 T or F or Y or N
2 True or False or Yes or No
getlogical is case independent.
Video output is via Borland's console i/o.
Return value returns 'Y' or 'N'
See also getc_match(), getci_match(), getk(), getyn(),
inkey(), inkeyc()
Example #include <keyboard.h>
main()
{
printf("This is good? ");
getlogical(2);
}
TCHK 2.0 Page 99
Function getreal - inputs a real from the keyboard
Syntax char *getreal(int size, int decimal);
Prototype in keyboard.h
Remarks getreal inputs a real (double) from the keyboard.
Only digits, decimal place, leading sign and
backspace are valid input. Input is terminated when
the ENTER key is pressed.
the maximum length of input is size and the maximum
number of decimal places is decimal. When
calculating size, you must leave enough room for
decimal, plus the number of places of the leading
integer, one for the decimal point and one for the
leading sign.
Video output is via Borland's console i/o.
Return value returns a string of the format [sn] [ddd] [.]
[ddd] where
[sn] = optional sign (+ or -)
[ddd] = optional digits
[.] = optional decimal point
See also getdouble(), getint()
Example #include <keyboard.h>
#include <stdio.h>
main()
{
char *c;
printf("Give me a real: ");
c = getreal(8,2);
printf("Your input is %s\n",c);
}
Program output Give me a real: -1012.30
Your input is -1012.30
TCHK 2.0 Page 100
Function getstr - input a string from the keyboard
Syntax char *getstr(int size, char *pattern);
Prototype in keyboard.h
Remarks getstr inputs a string from the keyboard, of
maximum length size, given a format pattern. See
getget() for a list of format modifiers.
The only other valid keys are backspace and ENTER.
Video output is via Borland's console i/o.
Return value returns a pointer to the storage location
containing the formatted string, or NULL if space
could not be allocated.
See also getget()
Example #include <keyboard.h>
#include <stdio.h>
main()
{
char *f, *l, *s, *c;
printf("First name: ");
f = getget(10,"A");
printf("Last name: ");
l = getget(20,"a");
printf("SS#: ");
s = getget(8,"9");
printf("Comments: ");
c = getget(60,"");
}
Program output First name: HOWARD
Last name: kapustein
SS#: 123456789
Comments: The empty quotes defaults to X.
TCHK 2.0 Page 101
Function getyn - get Yes/No
Syntax char getyn(int output);
Prototype in keyboard.h
Remarks getyn waits for a Y or N to be pressed and then
displays a message via putstr() according to
output:
output Message displayed
------ -----------------
0 no message
1 Y or N
2 Yes or No
getyn is case independent.
Video output is via Borland's console i/o.
Return value returns 'Y' or 'N'
See also getc_match(), getk(), getc_match(), getlogical(),
inkey(), inkeyc()
Example #include <keyboard.h>
main()
{
printf("Is this OK? ");
getyn(2);
}
TCHK 2.0 Page 102
Function gotohv - move cursor to absolute coordinates
Syntax void gotohv(int h, int v);
Prototype in video.h
Remarks gotoxy puts cursor at absolute screen coordinates
(h,v) via INT 0x10, Service 2. The top left corner
of the screen is referred to by (0,0).
This is NOT the same as Borland's gotoxy().
Borland's function is affected by the window()
settings, whereas gotohv() is not.
Return value nothing.
See also read_cursor(), whereh(), wherev()
Example #include <video.h>
main()
{
gotohv(0,0);
}
TCHK 2.0 Page 103
Function Greg... - family of Gregorian date conversion
functions
Syntax double GregtoCal(char *greg);
double GregtoCalCent(char *greg);
double GregEurotoCal(char *greg);
double GregEurotoCalCent(char *greg);
double GregJaptoCal(char *greg);
double GregJaptoCalCent(char *greg);
Prototype in datehk.h
Remarks GregtoCal converts Gregorian (US) dates to
Calendar dates
GregtoCalCent converts Gregorian (US) dates
to Calendar dates (w/century)
GregEurotoCal converts Gregorian (European)
dates to Calendar dates
GregEurotoCalCent converts Gregorian (European)
dates to Calendar dates
(w/century)
GregJaptoCal converts Gregorian (Japan)
dates to Calendar dates
GregJaptoCalCent converts Gregorian (Japan)
dates to Calendar dates
(w/century)
Return value GregtoCal, GregEurotoCal, GregJaptoCal return a
Calendar date
GregtoCalCent, GregEurotoCalCent, GregJaptoCalCent
return a Calendar date (w/century)
See also Appendix A
Cal...(), date_convert(), ddatetofull(),
ddatetoshort(), ddatetostr(), fulltoddate(),
Jul...(), monthexpand(), shorttoddate(),
strtoddate()
Example see demodate.c
TCHK 2.0 Page 104
Function horiz_line - draw a horizontal line
Syntax void horiz_line(byte c, int len, int col, int row);
Prototype in video.h
Remarks draws a horizontal line of characters c of length
len beginning at (col,row) via INTerrupts, using
the current char_attribute setting for color.
Screen coordinates are absolute.
horiz_line does no error checking on the passed
parameters.
Return value nothing.
See also box(), restore_box(), restore_screen(), save_box(),
save_screen(), vert_line()
Example #include <video.h>
main()
{
horiz_line('*',7,4,4); /* draw 7 *'s */
}
TCHK 2.0 Page 105
Function inkey - get a key
Syntax int inkey(boolean wait);
Prototype in keyboard.h
Remarks inkey returns the key code of the key pressed. If
no key was pressed (WAIT = FALSE) 0 is returned.
This function is similar to getchar() except input
is not echoed to the screen and inkey will detect
any key press (any standard keypress. It cannot
distinguish between the grey '+' key and the white
'+'. This function is interrupt driven. It will
detect ALT combinations, Del, PgUp, function keys,
etc., any keyboard INTerrupt accepted keys.)
Return value returns the key code of the key pressed, from 1 to
511. If WAIT = FALSE, and no key is pressed, zero
is returned.
See also keycode.h
getc_match(), getk(), getc_match(), getlogical(),
getyn(), inkeyc(), tocapkey()
Example #include <keyboard.h>
#include <stdio.h>
main()
{
int c;
c = inkey(WAIT);
printf("Key code # in keycode.h: %d\n", c);
}
TCHK 2.0 Page 106
Function inkeyc - get a key, any alphabetics capitalized
Syntax int inkeyc(boolean wait);
Prototype in keyboard.h
Remarks inkeyc returns the key code of the key pressed. If
no key was pressed (WAIT = FALSE) 0 is returned.
Any letters detected are capitalized before being
returned. This function is similar to getchar()
except input is not echoed to the screen and inkeyc
will detect any key press (any standard keypress.
It cannot distinguish between the grey '+' key and
the white '+'. This function is interrupt driven.
It will detect ALT combinations, Del, PgUp,
function keys, etc., any keyboard INTerrupt
accepted keys.)
Return value returns the key code of the key pressed, from 1 to
511, all letters are capitalized. If WAIT = FALSE,
and no key is pressed, zero is returned.
See also keycode.h
getc_match(), getk(), getc_match(), getlogical(),
getyn(), inkey(), tocapkey()
Example #include <keyboard.h>
#include <stdio.h>
main()
{
int c;
c = inkeyc(WAIT);
printf("Key code # in keycode.h: %d\n", c);
}
TCHK 2.0 Page 107
Function intlen - calculate length of integer in a string
Syntax int intlen(char *number);
Prototype in stringhk.h
Remarks intlen calculates the length of an integer in the
string number. The integer is terminated by a
non-digit (any character other than 0-9.) This
function is used internally by strcomma.
Return value the length of the integer pointed to by number.
Example #include <stringhk.h>
#include <stdio.h> /* for the printf */
#include <alloc.h> /* for the calloc */
main()
{
char *sint[15];
int len;
strcpy(sint,"1839.44");
printf("String: %s Length of integer: %d\n"
, sint, intlen(sint));
strcpy(sint,"19,848");
printf("String: %s Length of integer: %d\n"
, sint, intlen(sint));
strcpy(sint,"44x993");
printf("String: %s Length of integer: %d\n"
, sint, intlen(sint));
}
Program output String: 1839.44 Length of integer: 4
String: 19,848 Length of integer: 2
String: 44x993 Length of integer: 2
TCHK 2.0 Page 108
Function InsLock - set the Insert key state
Syntax void InsLock(boolean on);
Prototype in ibm.h
Remarks sets the Insert key state to the state selected by
the on parameter.
Return value nothing.
See also CapsLock(), NumLock(), SrollLock()
TCHK 2.0 Page 109
Function isAppendavail - is APPEND installed
Syntax boolean isAppendavail(void);
Prototype in doshk.h
Remarks checks if APPEND is installed.
Return value returns TRUE if APPEND is installed, FALSE
otherwise.
See also isAssignavail(), isShareAvail()
Example #include <ibm.h>
main()
{
printf("APPEND is ");
if (! isAppendavail())
printf("not ");
printf("installed\n");
}
TCHK 2.0 Page 110
Function isAssignavail - is ASSIGN installed
Syntax boolean isAssignavail(void);
Prototype in doshk.h
Remarks checks if ASSIGN is installed.
Return value returns TRUE if ASSIGN is installed, FALSE
otherwise.
See also isAppendavail(), isShareAvail()
Example #include <ibm.h>
main()
{
printf("ASSIGN is ");
if (! isAssignavail())
printf("not ");
printf("installed\n");
}
TCHK 2.0 Page 111
Function isBlogical - is drive B: logical
Syntax boolean isBlogical(void);
Prototype in ibm.h
Remarks checks if drive B: is logical or physical
Return value returns TRUE if drive B: is logical, FALSE
otherwise.
Example #include <ibm.h>
main()
{
printf("Drive B: is ");
if (isBlogical())
printf("logical\n");
else
printf("physical\n");
}
TCHK 2.0 Page 112
Function isBREAKon - check Ctrl-BREAK flag
Syntax #include <ibm.h>
isBREAKon();
Prototype in ibm.h
Remarks checks the state of the Ctrl-BREAK flag. The BREAK
status flag can be set from DOS by BREAK ON or
BREAK OFF.
This function is a macro.
Return value returns TRUE if the break flag is on, FALSE if the
flag is off.
See also isVERIFYon(), setBREAK(), setVERIFY()
Example #include <ibm.h>
main()
{
printf("BREAK flag is ");
if (! isBREAKon())
printf("not ");
printf("on\n");
}
TCHK 2.0 Page 113
Function isCGA - is Color Graphics adapter installed
isEGA - is Enhanced Graphics adapter installed
isHerc - is Hercules Graphics adapter installed
isMDA - is Monochrome adapter installed
ismono - is monochrome display
iscolor - is color display
Syntax boolean isMDA(void);
boolean isCGA(void);
boolean isEGA(void);
boolean isHerc(void);
#include <video.h>
ismono()
iscolor()
Prototype in video.h
Remarks is...() check if a video adapter is present.
ismono() checks if the display is mono.
iscolor() checks if the display is color.
The ismono() and iscolor() are macros. Use them if
you wish to check what attributes to use (underline
or red?) and use the adapter functions (isEGA,
etc.) for adapter specific tests.
Return value these functions return TRUE if the video adapter or
type, as the case may be, is present. Otherwise
they return FALSE.
See also video.h
Example #include <video.h>
main()
{
if (ismono()) /* monochrome */
if (isHerc())
printf("Hercules");
else
printf("MDA");
else /* color */
if (isEGA())
printf("EGA");
else
printf("CGA");
}
TCHK 2.0 Page 114
Function isdir - is a FAT entry a subdirectory
Syntax boolean isdir(char *fspec);
Prototype in filehk.h
Remarks checks if a FAT entry is a valid subdirectory. The
string fspec should be in the following format:
[d:][path]filename.ext[\]
where
d: = optional drive letter
path = optional path
filename.ext = the name of the FAT entry you
want to check
fspec may optionally have a \ at the end
Wildcards (*,?) are NOT supported and always cause
isdir to return FALSE.
This function does not harm the dta. The dta is
modified by this function, but restored before
returning.
Return value returns TRUE if fspec is a subdirectory, FALSE if
fspec does not exist or is not a subdirectory.
Example #include <filehk.h>
main()
{
char dirname[] = "a:\util\";
printf("%s is ",dirname);
if (! isdir())
printf("not ");
printf("a subdirectory\n");
}
TCHK 2.0 Page 115
Function isEMSavail - is EMS available
Syntax boolean isEMSavail(void);
Prototype in ibm.h
Remarks checks if EMS is installed.
Return value returns TRUE if EMS is present, otherwise FALSE.
See also ibm.h
EMMversion(), getEMSstatus(), EMSinfo(),
EMSpages(), EMSwarmbootprep()
Example #include <ibm.h>
main()
{
printf("EMS is ");
if (! isEMSavail())
printf("not ");
printf("available\n");
}
TCHK 2.0 Page 116
Function isExtended - is Extended memory installed
Syntax boolean isExtended(void);
Prototype in ibm.h
Remarks checks if Extended memory is installed.
Return value returns TRUE if Extended memory is installed, FALSE
otherwise.
See also Extendedtotal()
Example #include <ibm.h>
main()
{
printf("Extended memory is ");
if (! isExtended())
printf("not ");
printf("installed\n");
}
TCHK 2.0 Page 117
Function isgameport - is a game port installed
Syntax boolean isgameport(void);
Prototype in ibm.h
Remarks checks if a game port is installed.
Return value returns TRUE if a game port is installed, FALSE
otherwise.
Example #include <ibm.h>
main()
{
printf("Game port is ");
if (! isgameport())
printf("not ");
printf("installed\n");
}
TCHK 2.0 Page 118
Function isgn - sign of an integer
Syntax #include <mathhk.h>
(int) isgn(x)
Prototype in mathhk.h
Remarks isgn will determine the sign of x. Zero is
considered positive.
This function is a macro.
The macros sgn() and sign() are defined as isgn().
Return value returns -1 if x is negative, otherwise 1.
See also fsgn(), lsgn()
TCHK 2.0 Page 119
Function iskey102 - is an enhanced keyboard installed
Syntax boolean iskey102(void);
Prototype in ibm.h
Remarks checks if the keyboard is enhanced (102 keys or 101
in Europe). Does your keyboard have F11 and F12? If
so, it's an enhanced keyboard.
Return value returns TRUE if an enhanced keyboard is installed,
FALSE otherwise.
Example #include <ibm.h>
main()
{
printf("Keyboard is ");
if (iskey102())
printf("enhanced\n");
else
printf("old style (85 keys)\n");
}
TCHK 2.0 Page 120
Function isleapyear - is a year a leap year
Syntax boolean isleapyear(int checkyear);
Prototype in datehk.h (isleapyear)
Remarks checks if checkyear is a leap year (29 days in
February.)
Return value returns TRUE if checkyear is a leap year, FALSE
otherwise.
See also valid_date()
Example #include <datehk.h>
main()
{
int year;
/* assign some value to year */
printf("year %d is ",year);
if (! isleapyear(year))
printf("not ");
printf("a leap year\n");
}
TCHK 2.0 Page 121
Function isNetwork - is a network installed
Syntax boolean isNetwork(void);
Prototype in ibm.h
Remarks checks if a network is installed.
Return value returns TRUE if a network is installed, FALSE
otherwise.
Note this function requires DOS 3.1+
Example #include <ibm.h>
main()
{
printf("A network is ");
if (! isNetwork())
printf("not ");
printf("installed\n");
}
TCHK 2.0 Page 122
Function isPRINTavail - is PRINT.COM installed
Syntax int isPRINTavail(void);
Prototype in printhk.h
Remarks detects if PRINT.COM is installed.
Return value returns PRINT_ERROR if DOS 3.1 or greater is not
being used, otherwise returns PRINT_OK, PRINT_NOOK
or PRINT_INSTALLED, depending on the current
status.
Note requires DOS 3.1 or greater.
See also PRINTadd(), PRINThold(), PRINTpurge(),
PRINTremove(), PRINTresume
TCHK 2.0 Page 123
Function isPM - the the hour AM or PM
Syntax #include <timehk.h>
(boolean) isPM(hr)
Prototype in timehk.h
Remarks determines if hr in 24-hour army time is AM or PM.
Return value returns TRUE if hr is noon (12) or later or FALSE
if hr is AM.
See also time_convert(), to24hour(), tohour()
TCHK 2.0 Page 124
Function isShareavail - is SHARE installed
Syntax boolean isShareavail(void);
Prototype in doshk.h
Remarks checks if SHARE is installed.
Return value returns TRUE if SHARE is installed, FALSE
otherwise.
See also isAppendavail(), isAssignAvail()
Example #include <ibm.h>
main()
{
printf("SHARE is ");
if (! isShareavail())
printf("not ");
printf("installed\n");
}
TCHK 2.0 Page 125
Function isVERIFYon - check VERIFY flag
Syntax #include <ibm.h>
isVERIFYon()
Prototype in ibm.h
Remarks checks the state of the verify flag. The VERIFY
status flag can be set from DOS by VERIFY ON or
VERIFY OFF.
This function is a macro.
Return value returns TRUE if the verify flag is on, FALSE if the
flag is off.
See also isBREAKon(), setBREAK(), setVERIFY()
Example #include <ibm.h>
main()
{
printf("VERIFY flag is ");
if (! isVERIFYon())
printf("not ");
printf("on\n");
}
TCHK 2.0 Page 126
Function isVidclock - is VIDCLOCK.COM by Tom Hanlin
installed
Syntax boolean isVidclock(void);
Prototype in doshk.h
Remarks checks if VIDCLOCK.COM by Tom Hanlin is installed.
Return value returns TRUE if VIDCLOCK.COM is installed, FALSE
otherwise.
Example #include <ibm.h>
main()
{
printf("VidClock is ");
if (! isVidclock())
printf("not ");
printf("installed\n");
}
TCHK 2.0 Page 127
Function Jul... - family of Julian date conversion
functions
Syntax double JultoCal(double jul);
double JultoCalCent(double jul);
char *JultoGreg(double jul);
char *JultoGregEuro(double jul);
char *JultoGregJap(double jul);
struct ddate *Jultoddate(double jul);
double JulAtoCal(double jul);
double JulAtoCalCent(double jul);
char *JulAtoGreg(double jul);
char *JulAtoGregEuro(double jul);
char *JulAtoGregJap(double jul);
struct ddate *JulAtoddate(double jul);
double JulBtoCal(double jul);
double JulBtoCalCent(double jul);
char *JulBtoGreg(double jul);
char *JulBtoGregEuro(double jul);
char *JulBtoGregJap(double jul);
struct ddate *JulBtoddate(double jul);
Prototype in datehk.h
Remarks Jul.toCal converts a Julian date to Calendar
date
Jul.toCalCent converts a Julian date to Calendar
date (w/century)
Jul.toGreg... converts a Julian date to the
appropraite Gregorian date
Jul.toddate converts a Julian date to struct
ddate
Return value Jul.toCal return a Calendar date
Jul.toCalCent return a Calendar date (w/century)
Jul.toGreg.. return the appropriate Gregorian date
Jul.toddate return a struct ddate
See also Appendix A
Cal...(), date_convert(), ddatetofull(),
ddatetoshort(), ddatetostr(), fulltoddate(),
Greg...(), monthexpand(), shorttoddate(),
strtoddate()
Example see demodate.c
TCHK 2.0 Page 128
Function leftstr - return the left portion of a string
Syntax char *leftstr(char *source, int len);
Prototype in stringhk.h
Remarks leftstr performs just like its BASIC counterpart
LEFT$().
leftstr returns the left part of a string.
Return value leftstr returns the leftmost len characters of
source. If the length of source is less than len,
the entire string is returned.
leftstr returns a pointer to the storage location
containing the new string, or NULL if space could
not be allocated.
See also midstr(), rightstr()
Example #include <stringhk.h>
#include <stdio.h> /* for the printf */
main()
{
char msg[25], *l;
strcpy(msg,"This is another test");
l = leftstr(msg,7);
printf("%s\n",msg);
printf("%s\n",l);
}
Program output This is another test
This an
TCHK 2.0 Page 129
Function litebar_alloc - allocate memory for a litebar
menu
Syntax struct litebar_header *litebar_alloc(int left, int
top, int right, int bottom, char *frame,
char *title, int titlejustify, int count,
char *command[], int cmdleft[], int
cmdright[], int cmdup[], int cmddown[],
int cmdkey[], char cmdflag[], int cmdx[],
int cmdy[], char *message[], int msgx,
int msgy, int argq, int quitkey[], int
colframe, int coltitle, int colnorm, int
colcmdkey, int colhilite, int coldisable,
int coldishilite, int colnotopt, int
colmessage, int defaultcommand, unsigned
flags);
Prototype in menuhk.h
Remarks litebar_alloc creates a litebar menu with the
following information:
Coordinates of the frame of the litebar menu are
(left,top) to (right,bottom), the border, if any,
is made up of the 9 or 11 chars in frame (0 to 8 or
10) as per boxwindow(), with an optional title on
the top edge of the menu border, justified left,
right or center (see howard.h for more details). If
frame == NULL there will be no border. If
titlejustify = NONE there will be no title, or
pre-/post-title separators.
Unlike the popup menus, a count parameter is
required, specifiying how many commands there are.
The command array is a list of strings or text to
be displayed on the screen.
The cmdleft, cmdright, cmdup and cmddown parameters
are lists of where the respective key will move the
hilite bar. These values should correspond to an
index of the command[], with the exception noted
below. For example, if the hilite bar is on
command[0] and you wish the right arrow to move to
command[10], then cmdright[0] = 10. The exception
is when an arrow is to be disabled. Specifying a -1
as a direction element will disable that direction
for that command (i.e. at command[0] to make the
left arrow do nothing, then cmdleft[0] = -1.)
Each command can have a hotkey associated with it,
denoted by the appropriate cmdkey[]. The 'hotkey'
is actually a one-touch key, instantly moving to
and selecting a choice. The cmdkey value is an
TCHK 2.0 Page 130
offset into the command string. For example, a
command "Edit" with a hotkey of the "E" would have
a cmdkey value of 0 (an offset from the beginning
of the command). A command without a hotkey has a
cmdkey value of -1.
Each command has an appropriate cmdflag field. A
command may be either:
ENABLED - a valid choice
DISABLED - displayed, but not selectable
NOTOPTION - not a command (static text)
These are defined in menuhk.h. Other values may
cause unpredictable results.
The cmdx and cmdy arrays are lists of where the
commands should be displayed, respective to the
box. This is in a 'windowing' sense. If the box
coordinates are (10,10) to (20,20) and you wish
something to appear at the physical coordinates
(12,10) then (cmdx,cmdy) for the proper command
should be (2,0). This is an exception to the normal
coordinate system beginning at (1,1). In a litebar
menu, the 'border' is not excluded from the display
output and can be written over (this is true
regardless of whether or not a frame is displayed.)
TCHK litebar menus can display a message for each
command as it is hilited, much like Lotus style
menus. This message is optional, and if the
appropriate message[] is not NULL, it will be
displayed at (msgx,msgy). If the message[] element
is NULL, no message will be displayed. These
coordinates are relative to the menu coordinates,
just as cmdx and cmdy are.
A list of key codes that cause immediate return of
the user selection of the menu are in the quitkey
list, consisting of argq elements.
The following colors are used:
colframe - frame around menu (if any)
coltitle - title (if any)
colnorm - enabled commands
colcmdkey - hotkey in command
colhilite - currently hilited option
coldisable - disabled options
coldishilite - disabled and currently
hilited
colnotopt - static text (NOTOPTION)
colmessage - message (if any)
TCHK 2.0 Page 131
defaultcommand is the command initially hilited. If
an invalid command is chosen (the command is static
text, or does not exist, etc.) the first valid
command is the default.
flags is a 2-byte bit field of flags
QEFxxxxH xxIRCEDW
where
Q = Quit after selection
E = ESC means quit
F = Free memory on quit
H = Hierarchial menu (not implemented yet)
I = cmdkeys are case Independent
R = Restore cursor before returning
C = don't hide Cursor
E = Erase menu on free/cleanup
D = Disabled off (can be selected)
W = Wraparound
Briefly, Quit will restore the display to the state
it was in before the litebar menu was called
(settextinfo(), etc.). With E, if ESC is pressed
the menu is removed, for any other selection no
cleanup is done (unless Q is specified). Free
memory on quit calls litebar_free() after a
selection is made. Hierarchial menus are not
implemented yet. Keys are input via inkey() or
inkeyc(), depending on case Independency. When
litebar_get() is called, the cursor is hidden
unless C is given. The cursor is unhidden only if R
is given. E will cause the menu to be erased from
the screen if quitting. Disabled commands are not
normally selectable, unless D is on. Wraparound
allows the selecting hilite bar to wrap over the
top and under the bottom.
Return value allocates and returns a pointer to a litebar header
structure if the menu was successfully created,
otherwise returns NULL if an error occurred.
litebarerrno will have the following values:
0 success
1 error, could not allocate litebar header
2 error, could not allocate videosave
3 error, could not allocate menusave
4 error, invalid title justification
5 error, could not allocate popup field
7 error, no menu item enabled (no commands)
8 error, could not allocate quit keylist
TCHK 2.0 Page 132
Note The litebar_header structure contains important
information about the menu, including pointers to
linked lists for the fields, saved video displays,
etc. I strongly advise that you don't even think of
modifying this information yourself. Let the
litebar...() functions handle it for you. These
functions have been developed and used over a
period of several months, programs and conditions
which proves them to be vitually bug free. If you
really want to mess with them yourself, feel free.
But I certainly wouldn't want to attempt it.
Modifying these functions even with the srource
code is a headache.
See also menuhk.h
changelitebar(), litebar_free(), litebar_get(),
litehilite(), litemessage(), liteunlite()
litebarerrno
Example see demolite.c
TCHK 2.0 Page 133
Function litebar_free - frees memory allocated by a
litebar menu
Syntax void litebar_free(struct litebar_header *lh);
Prototype in menuhk.h
Remarks frees all memory allocated to a litebar menu.
Return value nothing.
Note see litebar_alloc()
See also menuhk.h
changelitebar(), litebar_alloc(), litebar_get(),
litehilite(), litemessage(), liteunlite()
litebarerrno
Example see demolite.c
TCHK 2.0 Page 134
Function litebar_get - get user's choice from a litebar
menu
Syntax int litebar_get(struct litebar_header *lh);
Prototype in menuhk.h
Remarks litebar_get does the actual prompting the user for
input. The following keys can be used to navigate
in the menu:
Up, Down, Move select bar to another
Left, Right command, as per parms to
litebar_alloc(). See
litebar_alloc() for more
details.
ENTER Select the hilited option
ESC Abort
in addition to any cmdkeys and quitkeys.
Other actions may be taken before returning from
this function, according to the flags for the menu.
See litebar_alloc() for more details.
Return value returns zero if ESC was hit. If an command was
chosen, litebar_get() returns the number of the
command selected. This is not the array index of
the command. If command[] has 3 static text items
and a command, and the command is selected, a 1
will be returned, even though the command is the
fourth command with a command index of three
(command[3]). If a quitkey was hit, the return
value will be the key code for the quitkey, plus
1000 (i.e. Ctrl-Z, key code 26, as a quitkey will
return 1026 when it is hit.)
See also menuhk.h
changelitebar(), litebar_alloc(), litebar_free(),
litehilite(), litemessage(), liteunlite()
litebarerrno
Example demolite.c
TCHK 2.0 Page 135
Function litehilite - hilite a litebar menu command
Syntax void litehilite(struct litebar_header *lh);
Prototype in menuhk.h
Remarks displays a litebar menu command in the hilited
color via Borland's console i/o.
This function is used internally by several
litebar...() menu functions.
Return value nothing.
Note This function is for internal uses only.
See also menuhk.h
changelitebar(), litebar_alloc(), litebar_free(),
litebar_get(), litemessage(), liteunlite()
litebarerrno
TCHK 2.0 Page 136
Function litemessage - change the message for a litebar
menu
Syntax void litemessage(struct litebar_header *lh,
int len);
Prototype in menuhk.h
Remarks changes the message for a litebar menu.
This function is used internally by several
litebar...() menu functions.
Return value nothing.
Note This function is for internal uses only.
See also menuhk.h
changelitebar(), litebar_alloc(), litebar_free(),
litebar_get(), litehilite(), liteunlite()
litebarerrno
TCHK 2.0 Page 137
Function liteunlite - unhilite a litebar menu command
Syntax void liteunlite(struct litebar_header *lh);
Prototype in menuhk.h
Remarks displays a litebar menu command in its unhilited
color(s).
This function is used internally by several
litebar...() menu functions.
Return value nothing.
Note This function is for internal uses only.
See also menuhk.h
changelitebar(), litebar_alloc(), litebar_free(),
litebar_get(), litehilite(), litemessage()
litebarerrno
TCHK 2.0 Page 138
Function lsgn - sign of a long integer
Syntax #include <mathhk.h>
(int) lsgn(x)
Prototype in mathhk.h
Remarks lsgn will determine the sign of x. Zero is
considered positive.
This function is a macro.
The macro lsign() is defined as lsgn().
Return value returns -1 if x is negative, otherwise 1.
See also fsgn(), isgn()
TCHK 2.0 Page 139
Function ltrim - trims leading blanks
Syntax char *ltrim(char *source);
Prototype in stringhk.h
Remarks remove leading blanks in a string. The string
passed to ltrim (source) is modified.
Return value returns a pointer to source.
Example #include <stringhk.h>
#include <stdio.h> /* for the printf */
main()
{
char msg[25] = " Hello everyone ";
printf("String [%s]\n",msg);
printf("ltrim [%s]\n",ltrim(msg));
}
Program output String [ Hello everyone ]
ltrim [Hello everyone ]
TCHK 2.0 Page 140
Function lotus_setup - creates info for menu_lotus()
Syntax void lotus_setup(int argc, byte *command[],
char cmdkey[], byte col[], byte
*message[], byte msglen[]);
Prototype in menuhk.h
Remarks lotus_setup does a lot of the grunt work necessary
to use menu_lotus() properly. Given the command and
message lists this function will create cmdkey[],
col[] and msglen[].
Return value nothing.
See also litebar...(), menu_lotus(), popup...()
Example see demo.c
TCHK 2.0 Page 141
Function machine_id - determine machine type
Syntax int machine_id(void);
Prototype in ibm.h
Remarks identifies the machine by use of the ROM byte and
model byte (available through a DOS call.)
Return value returns a code number depending on the machine
type. See ibm.h for more details.
Note This function cannot differentiate between a PS/2
Model 25 and PS/2 Model 30. However, the Model 30
has a hard drive, the Model 25 has none. For now
the Model 30 return code means the presence of a
Model 30 or a Model 25.
The PS/2 Model 70 cannot currently be identified
properly.
Also, the Portable PC cannot be 100% identified
through this function. Aside from the ROM byte
(which is identical to the XT) I don't know of any
distinguishing criteria. Anyone have ideas?
See also ibm.h
cpu_id(), ndp_id(), ROM_date(), ROM_id()
Example #include <ibm.h>
main()
{
printf("Machine ID() code = %d\n",
machine_id());
}
Program output Machine ID code = 1 /* on my PC */
TCHK 2.0 Page 142
Function memory_strategy - get/set memory alloc strategy
Syntax int memory_strategy(boolean read, int *strategy);
Prototype in ibm.h
Remarks this function will get or set the memory allocation
strategy. The variable read determines whether the
function will read or write (get or set) the
strategy value stored at *strategy.
Return value returns zero if successful (and *strategy is the
strategy being used) or, if an error occurs, the
error code (in which case the value in *strategy is
meaningless.)
Note this function requires DOS 3.xx.
See also ibm.h
Example #include <ibm.h>
#define GET TRUE /* read */
#define SET FALSE /* write */
main()
{
int memstrat;
if (memory_strategy(GET,&memstrat) !=
MEM_STRAT_BEST)
memory_strategy(SET,MEM_STRAT_BEST);
}
/* Bad, no error checking done. When you document
100+ functions, you write the best code, don't you? */
TCHK 2.0 Page 143
Function menu_lotus - Lotus style menu
Syntax char menu_lotus(int argc, char cmdkey[],
int *command[], int col[], int
*message[], int msglen[], int
normal, int highlite, int cmdrow,
boolean clockon, int clockrow, int
clockcol, int clockcolor);
Prototype in menuhk.h
Remarks menu_lotus displays a Lotus style 'slash bar' menu
and waits for a menu selection. This function is
modeled after the slash bar menu in Symphony. The
function parameters are:
argc number of menu choices
cmdkey array of the 1st letter of each
command (must be capitalized)
command menu choices
col columns of 1st letters of menu
commands (for displaying
command line)
message respective messages for menu
commands
msglen lengths of messages
normal color of text
highlite color of highlited option
cmdrow row to display command line on
clockon flag: display a clock?
clockrow row coordinate of clock
clockcol column coordinate of clock
clockcolor color of clock
menu_lotus will display an optional clock (clockon
= TRUE) that is updated every minute. The clock is
displayed as 11:44 PM.
All elements of cmdkey[] MUST be capitalized.
menu_lotus provides limited cursor control, as per
Symphony:
Up Arrow \ move hilite left 1 choice
Left Arrow /
Down Arrow \ move hilite right 1 choice
Right Arrow /
Home hilites first command
End hilites last command
Enter selects hilited menu choice
ESC selects nothing. Returns ESC
code
TCHK 2.0 Page 144
The cursor keys do not wraparound. Pressing right
arrow at the last menu choice does nothing.
All output is done via Borland's console i/o.
Return value returns the upper of the 1st letter of the menu
choice selected, or ESC (0x27) if ESC was pressed
Note This function is currently being rewritten to
conform more closely code- and option- wise with
the other menu functions (popup and litebar menus).
The final form will be similar to the litebar
menus, but with extra (and less) features to
conform with the Lotus style of menus (Symphony and
1-2-3 have similar, but different menu
manipulations). I guarrantee the revised version
will be worth the effort to rewrite your calls.
Currently, menu_lotus() does not work (unless you
want to crash your machine, in which case it does
the job fine.) See the note in the Revision
section.
See also litebar...(), lotus_setup(), popup...()
Example see testmenu.c
TCHK 2.0 Page 145
Function menu_popup - popup style menu
Syntax int menu_popup(int left, int top, int right, int
bottom, char frame[], char *title,
int titlejustify, char *command[],
int cmdkey[], char cmdflag[], int
colframe, int coltitle, int colnorm,
int colcmdkey, int colhilite, int
coldisable, int coldishilite, int
colnotopt, int defaultcommand,
unsigned flags);
Prototype in menuhk.h
Remarks an all-in-one function, menu_popup() is equivalent
to calling popup_alloc(), popup_get() and
popup_free(), with the flags Quit, Erase menu, case
Independent and Wraparound. See popup_alloc() and
popup_get for more details about parameters and
menu keys.
Return value returns zero if ESC was hit, otherwise returns the
number of the command selected. This is not the
array index of the command. If command[] has 3
static text items and a command, and the command is
selected, a 1 will be returned, even though the
command is the fourth command with a command index
of three (command[3]).
Note Use menu_popup() when you want a one-shot menu, and
the popup...() functions when you plan on keeping
the menu on the screen for multiple choices
(perhaps when overlaying submenus).
See also menuhk.h
popup_alloc(), popup_free(), popup_get(),
popup_restore(), popup_setcurrent(), pophilite(),
popunlite()
popuperrno
Example see demopop.c
TCHK 2.0 Page 146
Function mid - is a number within a range
Syntax #include <mathhk.h>
(boolean) mid(a,x,b)
Prototype in mathhk.h
Remarks mid checks if x is between a and b, inclusive.
This function is a macro.
Return value returns TRUE if x is between a and b, inclusive,
otherwise FALSE.
TCHK 2.0 Page 147
Function midstr - return the middle portion of a string
Syntax char *midstr(char *source, int begin, int len);
Prototype in stringhk.h
Remarks midstr performs just like its BASIC counterpart
MID$().
midstr returns the middle part of a string.
Return value midstr returns the substring of source, using begin
as the offset from the beginning to start the
substring, for len characters.
midstr returns a pointer to the storage location
containing the new string, or NULL if space could
not be allocated.
See also leftstr(), rightstr()
Example #include <stringhk.h>
#include <stdio.h> /* for the printf */
main()
{
char msg[25], *m;
strcpy(msg,"This is another test");
m = midstr(msg,5,7);
printf("%s\n",msg);
printf("%s\n",m);
}
Program output This is another test
is anot
TCHK 2.0 Page 148
Function monthexpand - convert a month abbrev to its name
Syntax char *monthexpand(int month);
Prototype in datehk.h
Remarks monthexpand returns the name of a month given its
numeric abbreviation.
monthexpand returns an element of a static char
array, so you should not make any changes directly
to the returned value, but rather copy the returned
value to a safe piece of memory.
Return value returns a pointer to the storage location
containing the date structure, or NULL if the month
given is invalid.
See also Months[], MonthAbbr[] (global variables)
Cal...(), date_convert(), ddatetofull(),
ddatetoshort(), ddatetostr(), fulltoddate(),
Greg...(), Jul...(), shorttoddate(), strtoddate()
Example #include <datehk.h>
main()
{
printf("Month 4 = %s\n",monthexpand(4));
}
Program output Month 4 = April
TCHK 2.0 Page 149
Function ndp_id - identify the math coprocessor
Syntax int ndp_id(void);
Prototype in chiphk.h
Remarks ndp_id does some opcode magic to identify the
numerical data processor (math coprocessor as it's
commonly called.) If a math coprocessor is present,
ndp_id recognizes the 8087, 80287, and the 80387.
ndp_id does not check dip switches but uses the
recommended method of identifying a math chip by
opcode instructions.
Return value returns a value identifying the math coprocessor.
See chiphk.h for further details.
Note Other (not 8087, 287 or 387) chips will not be
identified correctly.
For some reason this function keeps crashing on my
machine. Consider this function under works, not
necessarily finished. If you figure out what the
problem is, please let me know. I hope to have it
bug free by the next release, but time is at a
premium.
See also cpu_id(), machine_id()
TCHK 2.0 Page 150
Function NumLock - set the Num Lock key state
Syntax void NumLock(boolean on);
Prototype in ibm.h
Remarks sets the Num Lock key state to the state selected
by the on parameter.
Return value nothing.
See also CapsLock(), InsLock(), SrollLock()
TCHK 2.0 Page 151
Function parsefilename - parses a filename, supports paths
Syntax struct filespec *parsefilename(char *fspec);
Prototype in filehk.h
Remarks parsefilename parses a string pointed to by fspec
for a file name. The file name is placed in a
struct filespec as a drive, path, and filename.ext.
Wildcards are supported. The struct filespec is
returned as follows:
drive NULL (\0) if not given, else
drive letter
path NULL string ("") if not given,
else the path with a \ added to
the end of the path string
filename.ext NULL string ("") if no file
name given, else a filename.ext
as per standard DOS file names.
The filename.ext is not expanded (i.e. c:tchk.lib
has a filename.ext of tchk.lib, but c:tchk. has a
filename.ext of tchk., and c:tchk has a
filename.ext of tchk.).
parsefilename is intelligent enough to know that
c:. expands out to C:.\*.*, where . is a path.
parsefilename is very similar to Borland's
parsefnm(), except Borland's function does NOT
handle paths, whereas parsefilename will (since
parsefnm() is just a DOS call, and we all know who
writes that wonderful operating system MS-DOS,
don't we?)
Limited error checking is performed, so beware. The
string will be parsed properly, but errors due to
long strings (i.e. strlen(fspec) > 100) and other
miscellania can cause extensive damage due to
pointer manipulations.
Furthermore, an invalid string (i.e. C:\TC\;HK\Z.C)
will not be treated as an error. The string is
parsed from the beginning to look for a drive
letter, and scanned from the right to the left,
stopping at the first \. If a \ is found,
everything to the right of it is considered the
file name, everything to the left is the path
(excluding the drive). You are responsible for
making sure fspec is a valid DOS drive, path and
file name.
TCHK 2.0 Page 152
Return value parsefilename returns the DOS file name fspec
broken down into drive, path and filename.ext.
parsefilename returns a pointer to the storage
location containing the struct filespec, or NULL if
space could not be allocated.
See also getfilespec(), parsefnameext()
Example see demopars.c
TCHK 2.0 Page 153
Function parsefnameext - parses a filename into name and
extension
Syntax struct fnameext *parsefnameext(char *filename);
Prototype in filehk.h
Remarks parsefnameext parses a string pointed to by
filename into its elements, filename and extension.
The struct fnameext is returned with the file name
and extension as fixed length strings, padded with
spaces as necessary.
parsefnameext is useful for separating a DOS
filename into its discrete parts.
Return value parsefnameext returns the DOS file name filename
broken down into the structure fnameext as the name
and extension.
parsefnameext returns a pointer to the storage
location containing the struct fnameext, or NULL if
space could not be allocated.
See also getfilespec(), parsefilename()
Example see demopars.c
TCHK 2.0 Page 154
Function pause - wait for a time or until a keypress
Syntax int pause(int wait);
Prototype in timehk.h
Remarks waits for a time, or until a key is pressed.
Similiar to delay(), but can be aborted by a
keypress. wait is given in 1/100s of a second
Return value returns zero if the time elapsed, otherwise the
scan code of the key pressed.
TCHK 2.0 Page 155
Function PMT - calculate the periodic payment required to
fully amortize a principal
Syntax double PMT(double principal, double interest, int
periods)
Prototype in finance.h
Remarks PMT calculates the periodic payment required to
fully amortize a principal over some amount of
periods.
Return value returns the periodic payment required to fully
amortize a principal over an amount of periods.
See also FV(), FVa(), PV(), PVa()
TCHK 2.0 Page 156
Function popup_alloc - allocate memory for a popup menu
Syntax struct popup_header *popup_alloc(int left, int top,
int right, int bottom, char *frame,
char *title, int titlejustify, char
*command[], int cmdkey[], char
cmdflag[], int colframe, int
coltitle, int colnorm, int
colcmdkey, int colhilite, int
coldisable, int coldishilite, int
colnotopt, int defaultcommand,
unsigned flags);
Prototype in menuhk.h
Remarks popup_alloc creates a popup menu with the following
information:
Coordinates of the frame of the popup menu are
(left,top) to (right,bottom), the border is made up
of the 9 or 11 chars in frame (0 to 8 or 10) as per
boxwindow(), with an optional title on the top edge
of the menu border, justified left, right or center
(see howard.h for more details).
The command array is a list of strings or text to
be displayed on the screen. popup_alloc knows how
many commands it needs by the size of the box, one
per line (i.e. coordinates (1,1) to (10,5) would
need 3 commands since there are 3 lines inside the
popup box).
Each command can have a hotkey associated with it,
denoted by the appropriate cmdkey[]. The 'hotkey'
is actually a one-touch key, instantly moving to
and selecting a choice. The cmdkey value is an
offset into the command string. For example, a
command "Edit" with a hotkey of the "E" would have
a cmdkey value of 0 (an offset from the beginning
of the command). A command without a hotkey has a
cmdkey value of -1.
Each command has an appropriate cmdflag field. A
command may be either:
ENABLED - a valid choice
DISABLED - displayed, but not selectable
NOTOPTION - not a command (static text)
These are defined in menuhk.h. Other values may
cause unpredictable results.
TCHK 2.0 Page 157
The following colors are used:
colframe - frame around menu
coltitle - title (if any)
colnorm - enabled commands
colcmdkey - hotkey in command
colhilite - currently hilited option
coldisable - disabled options
coldishilite - disabled and currently
hilited
colnotopt - static text (NOTOPTION)
defaultcommand is the command initially hilited. If
an invalid command is chosen (the command is static
text, or does not exist, etc.) the first valid
command is the default.
flags is a 2-byte bit field of flags
QEFxxxxH xxIRCEDW
where
Q = Quit after selection
E = ESC means quit
F = Free memory on quit
H = Hierarchial menu (not implemented yet)
I = cmdkeys are case Independent
R = Restore cursor before returning
C = don't hide Cursor
E = Erase menu on free/cleanup
D = Disabled off (can be selected)
W = Wraparound
Briefly, Quit will restore the display to the state
it was in before the popup menu was called
(settextinfo(), etc.). With E, if ESC is pressed
the menu is removed, for any other selection no
cleanup is done (unless Q is specified). Free
memory on quit calls popup_free() after a selection
is made. Hierarchial menus are not implemented yet.
Keys are input via inkey() or inkeyc(), depending
on case Independency. When popup_get() is called,
the cursor is hidden unless C is given. The cursor
is unhidden only if R is given. E will cause the
menu to be erased from the screen if quitting.
Disbaled commands are not normally selectable,
unless D is on. Wraparound allows the selecting
hilite bar to wrap over the top and under the
bottom.
Return value allocates and returns a pointer to a popup header
structure if the menu was successfully created,
TCHK 2.0 Page 158
otherwise returns NULL if an error occurred.
popuperrno will have the following values:
0 success
1 error, could not allocate popup header
2 error, could not allocate videosave
3 error, could not allocate menusave
5 error, could not allocate popup field
6 error, could not allocate command string
7 error, no menu item enabled (no commands)
Note The popup_header structure contains important
information about the menu, including pointers to
linked lists for the fields, saved video displays,
etc. I strongly advise that you don't even think of
modifying this information yourself. Let the
popup...() functions handle it for you. These
functions have been developed and used over a
period of several months, programs and conditions
which proves them to be vitually bug free. If you
really want to mess with them yourself, feel free.
But I certainly wouldn't want to attempt it.
Modifying these functions even with the srource
code is a headache.
See also menuhk.h
menu_popup(), popup_free(), popup_get(),
popup_restore(), popup_setcurrent(), pophilite(),
popunlite()
popuperrno
Example see demopop.c
TCHK 2.0 Page 159
Function popup_free - frees memory allocated by popup menu
Syntax void popup_free(struct popup_header *ph);
Prototype in menuhk.h
Remarks frees all memory allocated to a popup menu.
Return value nothing.
Note see popup_alloc()
See also menuhk.h
menu_popup(), popup_alloc(), popup_get(),
popup_restore(), popup_setcurrent(), pophilite(),
popunlite()
popuperrno
Example see demopop.c
TCHK 2.0 Page 160
Function popup_get - get user's choice from a popup menu
Syntax int popup_get(struct popup_header *ph);
Prototype in menuhk.h
Remarks popup_get does the actual prompting the user for
input. The following keys can be used to navigate
in the menu:
Up Arrow Move select bar up one option
Down Arrow Move select bar down one option
Home Move select bar to first option
End Move select bar to last option
ENTER Select the hilited option
ESC Abort
in addition to any cmdkeys.
Other actions may be taken before returning from
this function, according to the flags for the menu.
See popup_alloc() for more details.
Return value returns zero if ESC was hit, otherwise returns the
number of the command selected. This is not the
array index of the command. If command[] has 3
static text items and a command, and the command is
selected, a 1 will be returned, even though the
command is the fourth command with a command index
of three (command[3]).
See also menuhk.h
menu_popup(), popup_alloc(), popup_free(),
popup_restore(), popup_setcurrent(), pophilite(),
popunlite()
popuperrno
Example see demopop.c
TCHK 2.0 Page 161
Function popup_restore - restore video from a popup menu
Syntax void popup_restore(struct popup_header *ph);
Prototype in menuhk.h
Remarks restores the display overlaid by a popup menu and
appropriate display information.
This function is used internally by several
popup...() menu functions.
Return value nothing.
Note This function is for internal uses only.
See also menuhk.h
menu_popup(), popup_alloc(), popup_free(),
popup_get(), popup_setcurrent(), pophilite(),
popunlite()
popuperrno
TCHK 2.0 Page 162
Function popup_setcurrent - set internal popup menu
information
Syntax int popup_setcurrent(struct popup_header *ph,
int current);
Prototype in
Remarks sets internal variables for a popup menu regarding
the currently hilited item.
This function is used internally by several
popup...() menu functions.
Return value returns return value for newly hilited command. IF
there are no other selectable commands, returns -1.
Note This function is for internal uses only.
See also menuhk.h
menu_popup(), popup_alloc(), popup_free(),
popup_get(), popup_restore(), pophilite(),
popunlite()
popuperrno
TCHK 2.0 Page 163
Function pophilite - hilite a popup menu command
Syntax void pophilite(struct popup_header *ph);
Prototype in menuhk.h
Remarks displays a popup menu command in the hilited color
via Borland's console i/o.
This function is used internally by several
popup...() menu functions.
Return value nothing.
Note This function is for internal uses only.
See also menuhk.h
menu_popup(), popup_alloc(), popup_free(),
popup_get(), popup_restore(), popup_setcurrent(),
popunlite()
popuperrno
TCHK 2.0 Page 164
Function popunlite - unhilite a popup menu command
Syntax void popunlite(struct popup_header *ph);
Prototype in menuhk.h
Remarks displays a popup menu command in its unhilited
color(s).
This function is used internally by several
popup...() menu functions.
Return value nothing.
Note This function is for internal uses only.
See also menuhk.h
menu_popup(), popup_alloc(), popup_free(),
popup_get(), popup_restore(), popup_setcurrent(),
pophilite()
popuperrno
TCHK 2.0 Page 165
Function print_screen - issue a PrintScreen
Syntax int print_screen(void);
Prototype in printhk.h
Remarks issues a Print Screen command as if PrtSc were
pressed.
Return value returns zero if the PrtSc is done, a one if the
PtrSc is in progress and 0xFF is an error occurred.
See printhk.h for further information.
See also isPRINTavail(), PRINTadd(), PRINThold(),
PRINTpurge(), PRINTremove(), PRINTresume
TCHK 2.0 Page 166
Function PRINTadd - add a file to the print queue
Syntax int PRINTadd(char *filename, int level);
Prototype in printhk.h
Remarks adds a file to the print queue. The filename may
NOT have wildcards. The priority level is
determined by level.
Return value returns zero if no error occurred, otherwise
returns the error code. See printhk.h for a full
list of the error return codes.
Note requires DOS 3.1 or greater.
See also isPRINTavail(), PRINThold(), PRINTpurge(),
PRINTremove(), PRINTresume
TCHK 2.0 Page 167
Function PRINThold - hold print queue for status read
Syntax int PRINThold(char far *queue);
Prototype in printhk.h
Remarks puts the print queue on hold and gets the status of
the print queue. The parameter queue is a far
pointer to a series of filename entries. Each entry
is 64 bytes long and contains a null terminated
string that is a file specification. The first file
specification in the queue is the one currently
being printed. The last slot in the queue is an
empty string (the first byte is '\0').
The print queue will not resume until a
PRINTresume() is issued.
Return value returns zero if no error occurred, otherwise
returns the error code. See printhk.h for a full
list of the error return codes.
Note requires DOS 3.1 or greater.
See also isPRINTavail(), PRINTadd(), PRINTpurge(),
PRINTremove(), PRINTresume
TCHK 2.0 Page 168
Function PRINTpurge - remove all files from print queue
Syntax int PRINTpurge(void);
Prototype in printhk.h
Remarks removes all files from the print queue.
Return value returns zero if no error occurred, otherwise
returns the error code. See printhk.h for a full
list of the error return codes.
Note requires DOS 3.1 or greater.
See also isPRINTavail(), PRINTadd(), PRINThold(),
PRINTremove(), PRINTresume
TCHK 2.0 Page 169
Function PRINTremove - remove a file from print queue
Syntax int PRINTremove(char *filename, int level);
Prototype in printhk.h
Remarks removes a file from the print queue. Wildcards are
allowed, so multiple files may be removed from the
queue with one call.
Return value returns zero if no error occurred, otherwise
returns the error code. See printhk.h for a full
list of the error return codes.
Note requires DOS 3.1 or greater.
See also isPRINTavail(), PRINTadd(), PRINThold(),
PRINTpurge(), PRINTresume
TCHK 2.0 Page 170
Function PRINTresume - resume printing after a PRINThold
Syntax int PRINTresume(void);
Prototype in printhk.h
Remarks resumes printing from the print queue after a
PRINTresume() has been issued. The print queue will
not resume until a PRINTresume() is issued.
Return value returns zero if no error occurred, otherwise
returns the error code. See printhk.h for a full
list of the error return codes.
Note requires DOS 3.1 or greater.
See also isPRINTavail(), PRINTadd(), PRINThold(),
PRINTpurge(), PRINTremove()
TCHK 2.0 Page 171
Function putk - put a character w/attribute on the screen
Syntax void putk(byte c);
Prototype in video.h
Remarks putk puts character c on the screen at the cursor
via INTerrupts. The cursor does NOT advance. The
attribute is set with the global variable
char_attribute.
Return value nothing.
See also putsay(), putstr(), set_color()
Example #include <video.h>
main()
{
gotohv(12,40);
putk('*');
}
TCHK 2.0 Page 172
Function putsay - put a string with attribute on the
screen
Syntax void putsay(int col, int row, byte *c);
Prototype in video.h
Remarks putsay puts string c on the screen at location
(col,row) via direct screen writes. It does retrace
checking to prevent snow on CGA systems. The
attribute is set with the global variable
char_attribute.
Return value nothing.
See also putk(), putstr(), set_color()
Example #include <video.h>
main()
{
putstr(12,40,(byte *)"Hello");
}
TCHK 2.0 Page 173
Function putstr - put string with attribute on the screen
Syntax void putstr(byte *c);
Prototype in video.h
Remarks putstr puts string c on the screen at the cursor
via INTerrupts. When finished the cursor will be 1
spot after the string. The attribute is set with
the global variable char_attribute.
Return value nothing.
See also putk(), putsay(), set_color()
Example #include <video.h>
main()
{
gotohv(12,40);
putstr((byte *)"Hello");
}
TCHK 2.0 Page 174
Function PV - calculate the Present Value of a single
amount
Syntax double PV(double payment, double interest, int
periods)
Prototype in finance.h
Remarks PV calculates the Present Value of a single amount
given the future value of the principal, the
interest rate per period and the number of periods.
Return value returns the present value of a single amount.
See also FV(), FVa(), PMT(), PVa()
TCHK 2.0 Page 175
Function PVa - calculate the Present Value of an annuity
Syntax double PVa(double payment, double interest, int
periods)
Prototype in finance.h
Remarks PVa calculates the Present Value of an annuity
given the amount of each payment, the interest rate
per period and the number of periods.
Return value returns the present value of an annuity.
See also FV(), FVa(), PMT(), PV()
TCHK 2.0 Page 176
Function read_attrib - gets the attribute under the cursor
Syntax byte read_attrib(void);
Prototype in video.h
Remarks gets the attribute under the cursor via INT 0x10,
Function 9.
Return value returns the attribute under the cursor.
See also read_char()
TCHK 2.0 Page 177
Function read_char - gets the character under the cursor
Syntax byte read_char(void);
Prototype in video.h
Remarks gets the character under the cursor via INT 0x10,
Function 9.
Return value returns the character under the cursor.
See also read_attrib()
TCHK 2.0 Page 178
Function read_cursor - reads cursor information
Syntax unsigned int read_cursor(int *row, int *col);
Prototype in video.h
Remarks reads the cursor location and scan lines via
INTerrupts.
Return value returns the scan lines of the cursor as a word, the
high order byte the start and low order byte the
end.
See also cursor_blink(), cursor_flip(), cursor_off(),
cursor_on(), getcursor(), set_cursor(),
setcursor(), whereh(), wherev()
Example #include <video.h>
main()
{
int x,y;
unsigned int scan;
scan = read_cursor(&x,&y);
printf("Scan start %d and end %d\n",
scan&0xFF00, scan&0xFF);
}
Program output Scan start 6 and end 7 /* on CGA */
TCHK 2.0 Page 179
Function read_mode - find screen width, mode and page
Syntax void read_mode(byte *width, byte *mode,
byte *page);
Prototype in video.h
Remarks detects the screen width (number of columns,) video
mode and video page via INT 0x10, Service 0x0F.
Return value nothing.
See also video.h
set_mode()
Example #include <video.h>
main()
{
byte width, mode, page;
read_mode(&width, &mode, &page);
printf("# columns: %d Mode: %d Page: %d\n",
width, mode, page);
}
Program output # columns: 80 Mode: 3 Page: 1
TCHK 2.0 Page 180
Function reboot - reboots the machine
Syntax void reboot(boolean warmboot);
Prototype in ibm.h
Remarks calling this function will reboot your machine via
the ROM reboot code located at F000:000. You can
specify a warm or cold boot (like hitting
CTRL-ALT-DEL or turning the power on.)
Return value nothing.
Example #include <ibm.h>
main()
{
boolean bootstyle;
/* set bootstyle */
reboot(bootstyle);
}
TCHK 2.0 Page 181
Function rightstr - return the right portion of a string
Syntax char *rightstr(char *source, int len);
Prototype in stringhk.h
Remarks rightstr performs just like its BASIC counterpart
MID$().
rightstr returns the middle part of a string.
Return value rightstr returns the rightmost len characters of
source. If the length of source is less than len,
the entire string is returned.
rightstr returns a pointer to the storage location
containing the new string, or NULL if space could
not be allocated.
See also leftstr(), midstr()
Example #include <stringhk.h>
#include <stdio.h> /* for the printf */
main()
{
char msg[25], *r;
strcpy(msg,"This is another test");
r = right(msg,7);
printf("%s\n",msg);
printf("%s\n",r);
}
Program output This is another test
er test
TCHK 2.0 Page 182
Function ROM_date - gets the ROM id date
Syntax byte ROM_date(void);
Prototype in ibm.h
Remarks finds the ROM id date at F000:FFF5
Return value returns a pointer to the storage location
containing the string, or NULL if space could not
be allocated.
See also ibm.h
machine_id(), ROM_id()
Example #include <ibm.h>
#include <stdio.h>
main()
{
printf("ROM BIOS date = %s",ROM_date());
}
Program output ROM BIOS date = 06/10/85
TCHK 2.0 Page 183
Function ROM_id - gets the ROM id byte
Syntax byte ROM_id(void);
Prototype in ibm.h
Remarks finds the ROM id byte at F000:FFFE
Return value returns the ROM id byte
Note on Compaq machines the ROM id byte is found at a
memory location close to, but not at, F000:FFFE.
Not having access to a Compaq, I did not include a
check for this. Maybe a future version...
See also ibm.h
machine_id(), ROM_date()
Example #include <ibm.h>
#include <stdio.h>
main()
{
printf("ROM id byte = %X",ROM_id());
}
Program output ROM id byte = FF
TCHK 2.0 Page 184
Function round - round a real to a decimal place
Syntax double round(double x, int n);
Prototype in mathhk.h
Remarks round will round off a double to x amount of
decimal places. Only zero or greater values are
valid for n (non-zegative). No error checking is
done.
Return value returns x rounded to n decimal places.
See also frac()
Example #include <mathhk.h>
main()
{
printf("Round %lf to %d places = %lf\n",2.307,
2,round(2.307,2));
Program output Round 2.307 to 2 places = 2.31
Example see demonum.c
TCHK 2.0 Page 185
Function rtrim - trims trailing blanks
Syntax char *rtrim(char *source);
Prototype in stringhk.h
Remarks removes trailing blanks in a string. The string
passed to rtrim (source) is modified.
Return value returns a pointer to source.
Example #include <stringhk.h>
#include <stdio.h> /* for the printf */
main()
{
char msg[25] = " Hello everyone ";
printf("String [%s]\n",msg);
printf("rtrim [%s]\n",rtrim(msg));
}
Program output String [ Hello everyone ]
rtrim [ Hello everyone]
TCHK 2.0 Page 186
Function scrbuff - calculate size of screen buffer
Syntax #include <video.h>
scrbuff(l,t,r,b)
Prototype in video.h
Remarks this is really just a define to calculate the size
of a buffer need by Borland's gettext() and
puttext() functions.
Return value returns the number of bytes needed to store a
segment of screen from (l,t) to (r,b), with
attributes.
See also video.h
TCHK 2.0 Page 187
Function scroll_down - scroll window down
Syntax void scroll_down(int left, int top, int right,
int bottom);
Prototype in video.h
Remarks scroll a box, delineated by the coordinates, down 1
line. A blank line will be inserted at the top, and
the bottom line will be lost. The scrolling is done
via INT 0x10, Function 7. Coordinates are absolute.
Return value nothing.
See also scroll_up()
Example #include <video.h>
main()
{
scroll_down(0,0,4,79);
/* scroll bottom 4 lines */
}
TCHK 2.0 Page 188
Function scroll_up - scroll window up
Syntax void scroll_up(int left, int top, int right,
int bottom);
Prototype in video.h
Remarks scroll a box, delineated by the coordinates, up 1
line. A blank line will be inserted at the bottom,
and the top line will be lost. The scrolling is
done via INT 0x10, Function 6. Coordinates are
absolute.
Return value nothing.
See also scroll_down()
Example #include <video.h>
main()
{
scroll_up(0,0,4,79); /* scroll top 4 lines */
}
TCHK 2.0 Page 189
Function ScrollLock - set the Scroll Lock key state
Syntax void ScrollLock(boolean on);
Prototype in ibm.h
Remarks sets the Scroll Lock key state to the state
selected by the on parameter.
Return value nothing.
See also CapsLock(), InsLock(), NumLock()
TCHK 2.0 Page 190
Function set_color - set the default attribute (color)
Syntax void set_color(byte colors);
Prototype in video.h
Remarks set_color just sets the global variable
char_attribute to colors. I got tired of declaring
char_attribute as extern in every function that
output to the screen, so I made this function.
Return value nothing.
See also putk(), putstr()
Example #include <video.h>
#include <color.h>
main()
{
set_color(RED | B_WHITE | BLINK);
/* red blinking text on white background */
gotoxy(12,40);
putstr((byte *)"Hello");
}
TCHK 2.0 Page 191
Function set_cursor - sets cursor scan lines
Syntax #include <video.h>
set_cursor(h,l)
Prototype in video.h
Remarks sets the cursor scan lines via setcursor(), passing
h | l as the cursor scan code.
This function is a macro.
Return value nothing.
See also cursor_blink(), cursor_flip(), cursor_off(),
cursor_on(), getcursor(), read_cursor(),
setcursor()
Example #include <video.h>
main()
{
set_cursor(0,7);
}
TCHK 2.0 Page 192
Function set_handles - set handle count
Syntax int set_handles(int handles);
Prototype in filehk.h
Remarks sets the handle count via DOS Function 0x67. If
more than 255 handles are specified (the maximum
allowable) set_handle tries to set the handle count
to 255.
Return value returns zero if execution was successful, a nonzero
error code otherwise.
Note This function requires DOS 3.3+.
Example #include <filehk.h>
main()
{
set_handles(127);
}
TCHK 2.0 Page 193
Function set_mode - set the video mode
Syntax void set_mode(byte mode);
Prototype in video.h
Remarks sets the video mode via INT 0x10, Service 0.
Return value nothing.
See also video.h
read_mode()
Example #include <video.h>
main()
{
set_mode(3); /* text mode */
printf("# columns: %d Mode: %d Page:
%d\n", width, mode, page);
}
Program output # columns: 80 Mode: 3 Page: 1
TCHK 2.0 Page 194
Function setBREAK - set Ctrl-BREAK flag
Syntax #include <ibm.h>
boolean setBREAK(boolean break_status);
Prototype in ibm.h
Remarks sets the state of the Ctrl-BREAK flag. The BREAK
status flag can be set from DOS by BREAK ON or
BREAK OFF.
This function is a macro.
Return value returns TRUE if the break flag is on, FALSE if the
flag is off.
Note the return value is based on the CURRENT setting.
If you set the break flag, setBREAK will return
what you set the flag to, not what the flag was set
to before.
See also isBREAKon(), isVERIFYon(), setVERIFY()
Example #include <ibm.h>
main()
{
printf("BREAK flag was ");
if (! setBREAK(TRUE))
printf("not ");
printf("on\n");
}
TCHK 2.0 Page 195
Function setcursor - sets cursor scan lines
Syntax void set_cursor(unsigned int cursor);
Prototype in video.h
Remarks sets the cursor scan lines via INT 0x10, Function
1.
Return value nothing.
See also cursor_blink(), cursor_flip(), cursor_off(),
cursor_on(), getcursor(), read_cursor(),
set_cursor()
Example #include <video.h>
main()
{
setcursor(7);
}
TCHK 2.0 Page 196
Function settextinfo - set text mode video information
Syntax void settextinfo(struct text_info *inforec);
Prototype in video.h
Remarks settextinfo sets the Borland internal text mode
settings to the values in the text_info structure
pointed to by inforec, in the following order:
mode (via textmode())
window (via window())
attribute (via textattr())
cursor location (via gotoxy())
Only those settings needed to be modified are
actually changed.
This function does the exact opposite of
gettextinfo(), and was designed to be used in
conjunction with it. Do a gettextinfo() to save the
current settings, do whatever, then restore the
settings via settextinfo().
Return value nothing.
TCHK 2.0 Page 197
Function setVERIFY - set VERIFY flag
Syntax #include <ibm.h>
boolean setVERIFY(boolean verify_status);
Prototype in ibm.h
Remarks sets the state of the verify flag. The VERIFY
status flag can be set from DOS by VERIFY ON or
VERIFY OFF.
This function is a macro.
Return value returns TRUE if the verify flag is on, FALSE if the
flag is off.
Note the return value is based on the CURRENT setting.
If you set the verify flag, setVERIFY will return
what you set the flag to, not what the flag was set
to before.
See also isBREAKon(), isVERIFYon(), setBREAK()
Example #include <ibm.h>
main()
{
printf("VERIFY flag was ");
if (! setVERIFY(TRUE))
printf("not ");
printf("on\n");
}
TCHK 2.0 Page 198
Function shorttoddate - convert a short date to struct
Syntax struct ddate *shorttoddate(char *source);
Prototype in datehk.h
Remarks shorttoddate converts a date from a short date
format to the structure ddate format
Return value returns a pointer to the storage location
containing the date structure, or NULL if space
could not be allocated.
See also see Appendix A
Cal...(), date_convert(), ddatetofull(),
ddatetoshort(), ddatetostr(), fulltoddate(),
Greg...(), Jul...(), monthexpand(), strtoddate()
Example see demodate.c
TCHK 2.0 Page 199
Function sqr - square of a value
Syntax #include <mathhk.h>
(type) sqr(x)
Prototype in mathhk.h
Remarks sqr will calculate the square of x.
This function is a macro.
Return value returns the square of x.
TCHK 2.0 Page 200
Function stddev - calculate the standard deviation of a
set of reals
Syntax double stddev(int n, double element[]);
Prototype in mathhk.h
Remarks variance calculates the standard deviation of a set
of n numbers of type double.
Return value returns the standard deviation of a set of n
numbers.
See also average(), summation(), variance()
Example #include <mathhk.h>
main()
{
double num[] = { 2.3, 7.1, 6.05 };
printf("Std dev is %.9lf\n",stddev(3,num));
}
Program output Std dev is 2.060339778
TCHK 2.0 Page 201
Function straight_line_dep - calculate straight line
depreciation
Syntax double straight_line_dep(double cost, double
salvage, int life);
Prototype in finance.h
Remarks given the cost, salvage value and life of an item,
straight_line_dep will calculate the periodic
deprecitation according to the straight line method
of depreciation. The cost and salvage can be given
in any unit (dollars, thousands of dollars, etc.)
but the life should be given in depreciable periods
(if you depreciate an item every quarter, and the
item has a life of 2 years, then life should be 8.)
The cost and salvage values should be in the same
units.
No error checking is performed.
Return value returns the periodic depreciation in the same units
as the cost, as per the straight line depreciation
method.
Note The macro SLD(c,s,l) is defined in finance.h for
ease of use.
See also accum_dep(), depreciation(),
double_decline_bal_dep(), sum_year_digits_dep()
Example see demonum.c
TCHK 2.0 Page 202
Function strcapital - capitalizes the first letter of each
word in a string
Syntax char *strcapital(char *str);
Prototype in stringhk.h
Remarks strcapital capitalizes the first letter of each
word in the string str. A word is defined an an
alphabetic sequence of letters. The string passed
to strcapital is modified.
Return value returns str.
TCHK 2.0 Page 203
Function strclean - remove non-printable ASCII codes
Syntax char *strclean(char *str);
Prototype in stringhk.h
Remarks strclean removes any non-printable ASCII characters
from the string str. Non-printable is defined as
per the isprint() function. The string passed to
strclean is modified.
Return value returns str.
TCHK 2.0 Page 204
Function strcomma - convert a string to xx,xxx,xxx format
Syntax char *strcomma(char *source);
Prototype in stringhk.h
Remarks strcomma converts a string of numbers into the
comma delimited format (xx,xxx,xxx). The number is
terminated by a non-digit (any character other than
0-9.) A leading sign will be copied before
converting the number.
Return value returns a pointer to the storage location
containing the comma formatted string, or NULL if
space could not be allocated. The returned string
is NOT the same as the string passed to the
function. This function does NOT write over the
string passed to it.
See also strtocomma()
Example #include <stringhk.h>
#include <stdio.h> /* for the printf */
main()
{
char sint[15], *comma;
strcpy(sint,"12839.44");
comma = strcomma(sint);
printf("%s -> %s\n",sint,comma);
}
Program output 12839.44 -> 12,839.44
TCHK 2.0 Page 205
Function strdel - delete part of a string
Syntax char *strdel(char *source, char *old);
Prototype in stringhk.h
Remarks strdel deletes the first occurence of the string
old from the string source. This function is case
dependent.
Return value returns source
Example #include <stringhk.h>
#include <stdio.h> /* for the printf */
main()
{
char msg[45], fragment[15], *new;
strcpy(msg,"Did you register yet? Did you?");
strcpy(fragment,"you");
printf(" [%s]\n",msg);
printf("- [%s]\n",fragment);
new = strdel(msg,fragment);
printf("= [%s]\n",new);
}
Program output [Did you register yet? Did you?]
- [you]
= [Did register yet? Did you?]
TCHK 2.0 Page 206
Function strfill - fill a string with a character
Syntax char *strfill(char *str, char c, int count);
Prototype in stringhk.h
Remarks strfill makes a string of c characters of count
length.
Similar to strrep(), strfill() uses an existing
piece of memory pointed to by str. Functions like
strnset set a piece of memory with a character, but
do not make it a valid C string (null terminated.)
Return value returns the pointer passed to strfill.
See also strrep()
TCHK 2.0 Page 207
Function strins - insert one string into another
Syntax char *strins(char *source, char *new, char *ptr);
Prototype in stringhk.h
Remarks strins inserts the string new into the string
source at the location ptr in source. Basically,
strins copies source up to, but not including, ptr
into a new location, concatenates the new
(inserted) string, and then concatenates the
remainder of source (the string pointed to by ptr.)
Return value returns a pointer to the storage location
containing the newly concatenated string, or NULL
if space could not be allocated. The returned
string is NOT the same as the string passed to the
function. This function does NOT write over the
string passed to it.
Example #include <stringhk.h>
#include <stdio.h> /* for the printf */
main()
{
char old[25], *ptr, *new;
strcpy(old,"ABCDEFG");
ptr = old + 3; /* *ptr = 'D' */
new = strins(old,"abc",ptr);
printf("%s -> %s\n",old,new);
}
Program output ABCDEDFG -> ABCabcDEFG
TCHK 2.0 Page 208
Function stroccur - count the occurences of a substring
within a string
Syntax int stroccur(str *str, char *substr);
Prototype in stringhk.h
Remarks stroccur counts the number of times the string
substr appears with the string str.
Return value returns the number of times the string substr
appears within the string str.
Example #include <stringhk.h>
#include <stdio.h> /* for the printf */
main()
{
char original[] = "This is his test";
printf("%d\n",stroccur(original,"is"));
}
Program output 3
TCHK 2.0 Page 209
Function strrep - replicate a char
Syntax char *strrep(char c, int len);
Prototype in stringhk.h
Remarks strrep creates a string len long entirely of
character c.
Return value returns a pointer to the storage location
containing the newly replicated string, or NULL if
space could not be allocated.
Example #include <stringhk.h>
#include <stdio.h> /* for the printf */
main()
{
char *rep;
printf("%s\n",rep = strrep('k',7));
}
Program output kkkkkkk
TCHK 2.0 Page 210
Function strshleft - shift string left
Syntax void strshleft(char *source, int count);
Prototype in stringhk.h
Remarks strshleft shifts the characters in the string
source left count places, padding with spaces.
Return value returns source.
Example #include <stringhk.h>
#include <stdio.h> /* for the printf */
main()
{
char msg[25];
strcpy(msg,"Buy a Mac II");
printf("%s\n",msg);
printf("%s\n",strshleft(msg,4));
}
Program output Buy a Mac II
a Mac II
TCHK 2.0 Page 211
Function strshright - shift string right
Syntax void strshright(char *source, int count);
Prototype in stringhk.h
Remarks strchright shifts the characters in the string
source right count places, padding with spaces.
Return value returns source.
Example #include <stringhk.h>
#include <stdio.h> /* for the printf */
main()
{
char msg[25];
strcpy(msg,"Buy a Mac II");
printf("%s\n",msg);
printf("%s\n",strshright(msg,4));
}
Program output Buy a Mac II
Buy a Ma
TCHK 2.0 Page 212
Function strtocomma - convert a string to xx,xxx format
Syntax char *strtocomma(char *source);
Prototype in stringhk.h
Remarks strtocomma converts a string of numbers into the
comma delimited format (xx,xxx,xxx). The number is
terminated by a non-digit (any character other than
0-9.) A leading sign will be copied before
converting the number.
The comma delimited string will be returned in
source, so you must make sure there is sufficient
space allocated.
Return value returns a pointer to source. This function writes
over the string passed to it.
See also strcomma()
Example #include <stringhk.h>
#include <stdio.h> /* for the printf */
main()
{
char temp[15];
strcpy(temp,"12839.44");
printf("-> %s\n",strtocomma(temp));
}
Program output -> 12,839.44
TCHK 2.0 Page 213
Function strtoddate - convert a date string to a structure
Syntax struct ddate *strtoddate(char *source);
Prototype in datehk.h
Remarks strtoddate converts a date abbreviation to a
structure of type ddate. The abbreviation can use
dashes or slashes (- or /) to separate the fields
of the date. All fields MUST be of length two (i.e.
02/07/87 is valid, but 2/7/87 and 02/07/1987 are
not valid.)
Return value returns a pointer to the storage location
containing the date structure, or NULL if space
could not be allocated.
See also Cal...(), date_convert(), ddatetofull(),
ddatetoshort(), ddatetostr(), fulltoddate(),
Greg...(), Jul...(), monthexpand(), shorttoddate()
Example #include <datehk.h>
main()
{
struct ddate *today;
char strtoday[9];
strcpy(strtoday,"04/01/67");
if ((today = strtoddate(strtoday) != NULL) {
printf("today is %d-%d-%d\n",
today->dmon, today->dday,
today->dyear);
printf("or %s\n", strtoday);
}
}
Program output today is 4-1-67
or 04/01/67
TCHK 2.0 Page 214
Function strtodol - converts a string to dollar format
Syntax char *strtodol(char *source);
Prototype in stringhk.h
Remarks strtodol converts a string pointed to by source to
dollar format ($-12,839.44). An optional leading
sign is copied. Only the first 2 decimal places are
copied (the string is truncated, not rounded.)
Return value returns a pointer to the storage location
containing the dollar formatted string, or NULL if
space could not be allocated. The returned string
is NOT the same as the string passed to the
function. This function does NOT write over the
string passed to it.
Example #include <stringhk.h>
#include <stdio.h> /* for the printf */
main()
{
char sint[15], *dollar
strcpy(sint,"12839.44");
dollar = strtodol(sint);
printf("%s -> %s\n",sint,dollar);
free(dollar);
strcpy(sint,"+62939445.1");
dollar = strtodol(sint);
printf("%s -> %s\n",sint,dollar);
free(dollar);
}
Program output 12839.44 -> $12,839.44
+62939445.1 -> $+62,939,445.10
TCHK 2.0 Page 215
Function strtotime - convert a string to a time structure
Syntax struct time *strtotime(char *source);
Prototype in timehk.h
Remarks strtotime converts a string to a time structure,
checking for AM/PM or 24-hour format. If seconds or
hundredths of seconds are not in the string, their
values will be set to 0 in the structure.
Return value returns a pointer to the storage location
containing the time string, or NULL if space could
not be allocated.
See also timetostr()
Example #include <timehk.h>
main()
{
struct time *now;
strcpy(strnow,"5:12 PM");
if ((now = strtotime(strnow)) != NULL)
printf("%d hours, %d min, %d.%d secs\n",
now->ti_hour, now->ti_min,
now->ti_sec, now->ti_hund);
}
Program output 17 hours, 12 min, 0.0 secs
TCHK 2.0 Page 216
Function strwcmp - compares a wild-carded string to
another string
Syntax int strwcmp(char *wstr, char *str);
Prototype in stringhk.h
Remarks strwcmp performs an unsigned comparison of wstr and
str, starting with the first character in each
string and continuing with subsequent characters
until the corresponding characters differ or until
the end of the strings is reached. Wildcards (*,?)
are supported, as per DOS (* wildcards 0 or more
characters, ? wildcards a single character).
Return value strwcmp returns an int value that is
< 0 if wstr is less than str
= 0 if wstr is the same as str
> 0 if wstr is greater than str
Furthermore, if a comparison falls through during a
wildcard matching, -2 or 2 is returned. If a
mismatch is found without using wildcards, a -1 or
1 is returned.
See also strwicmp()
TCHK 2.0 Page 217
Function strwicmp - compares a wild-carded string to
another string, without case
sensitivity
Syntax int strwicmp(char *wstr, char *str);
Prototype in stringhk.h
Remarks strwicmp performs an unsigned comparison of wstr
and str, starting with the first character in each
string and continuing with subsequent characters
until the corresponding characters differ or until
the end of the strings is reached. Wildcards (*,?)
are supported, as per DOS (* wildcards 0 or more
characters, ? wildcards a single character). The
comparison is not case sensitive.
Return value strwicmp returns a value that is
< 0 if wstr is less than str
= 0 if wstr is the same as str
> 0 if wstr is greater than str
Furthermore, if a comparison falls through during a
wildcard matching, -2 or 2 is returned. If a
mismatch is found without using wildcards, a -1 or
1 is returned.
See also strwcmp()
TCHK 2.0 Page 218
Function sum_year_digits_dep - calculate sum of the years
digits depreciation
Syntax double sum_year_digits_dep(double cost, double
salvage, int life, int period);
Prototype in finance.h
Remarks given the cost, salvage value and life of an item,
sum_year_digits_dep will calculate the amount of
deprecitation for the given period according to the
sum of the years digits depreciation method. The
cost and salvage can be given in any unit (dollars,
thousands of dollars, etc.) but the life should be
given in depreciable periods (if you depreciate an
item every quarter, and the item has a life of 2
years, then life should be 8).
The cost and salvage values should be in the same
units. The life and period should be given in the
same units.
No error checking is performed.
Return value returns the amount of depreciation for the given
period in the same units as the cost, as per the
sum of the years digits depreciation method.
Note The macro SYD(c,s,l,p) is defined in finance.h for
ease of use.
See also accum_dep(), depreciation(),
double_decline_bal_dep(), straight_line_dep()
Example see demonum.c
TCHK 2.0 Page 219
Function summation - calculate a summation of integers
Syntax int summation(int max);
Prototype in mathhk.h
Remarks summation calculates a summation denoted by Σ Xi
where i ranges from 1 to max. Beware of overflow,
calculations are done as ints.
Return value returns the summation denoted by Σ Xi where i
ranges from 1 to max. If max <= 1, summation
returns a 1.
See also average(), factorial(), stddev(), variance()
Example #include <mathhk.h>
main()
{
printf("Summation is %d\n",summation(10));
}
Program output Summation is 55
TCHK 2.0 Page 220
Function swap - swap two values
Syntax #include <mathhk.h>
(void) swap(x,y)
Prototype in mathhk.h
Remarks swap will swap two values, regardless of type, but
should be of equal type.
This function is a macro.
Return value nothing.
TCHK 2.0 Page 221
Function time_convert - convert time formats
Syntax boolean time_convert(void *source, void *dest,
int stype, int dtype);
Prototype in timehk.h
Remarks time_convert will convert a time from virtually any
time format to any other. The parameters *source
and *dest must be pointers pointing to a piece of
memory allocated as the proper data type. stype and
dtype determine the format of source and dest.
Due to the great number of formats supported, a
chart of valid time formats is provided in Appendix
C.
Limited error checking is done on passed data. If
an invalid time format is passed, unpredictable
results will occur.
Return value returns TRUE is the conversion was successful and
FALSE if the time could not be converted.
Note This function does NO function calls. I've tried to
optimize this function as much as possible for
speed, not size. If you only need to convert
between a couple of specific formats, you may be
better off doing a pair of sprintfs.
See also Appendix C
strtotime(), timetostr()
Example see demotime.c
TCHK 2.0 Page 222
Function timetostr - convert time structure to a string
Syntax char *timetostr(struct time *tsource,
boolean seconds, boolean hundreds,
boolean ampm);
Prototype in timehk.h
Remarks timetostr converts a time structure to a string,
with the following options:
seconds = put seconds in string
hundreds = put hundreths of seconds in string
ampm = append AM/PM to string
if ampm is FALSE, 24-hour time will be used.
if hundreds is TRUE, seconds are automatically put
into the string.
Return value returns a pointer to the storage location
containing the time string, or NULL if space could
not be allocated.
See also strtotime()
Example #include <timehk.h>
main()
{
char *strnow;
struct time now;
gettime(&now);
if ((strnow = timetostr(&now, FALSE, TRUE,
TRUE)) != NULL)
printf("The time is %s\n",strnow);
}
Program output The time is 11:23:14.22 PM
TCHK 2.0 Page 223
Function tocapkey - convert the key code to uppercase
Syntax int tocapkey(int k);
Prototype in keyboard.h
Remarks if the key code k is a letter, it is converted to
upper case.
Return value if the key code is a lower case letter, tocapkey
returns the upper case of that letter, otherwise
tocapkey returns the key code unchanged
See also inkey(), inkeyc()
TCHK 2.0 Page 224
Function to24hour - converts hours to 24-hour format
Syntax #include <timehk.h>
(int) to24hour(hr)
Prototype in timehk.h
Remarks converts midnight (0) to the 24th hour.
Return value returns 0 if hr is midnight (0), otherwise returns
hr.
See also isPM(), time_convert(), tohour()
TCHK 2.0 Page 225
Function todosdate - make a DOS file date stamp
Syntax #include <doshk.h>
(unsigned) todosdate(y,m,d)
Prototype in doshk.h
Remarks makes a DOS file date stamp. Refer to a DOS
reference book (Advanced MS-DOS by Ray Duncan
recommended) for further details.
This function is a macro.
Return value returns the DOS file date stamp.
See also dosday(), doshour(), dosmonth(), dosmin(),
dossec(), dosyear(), todostime()
TCHK 2.0 Page 226
Function todostime - make a DOS file time stamp
Syntax #include <doshk.h>
(unsigned) todostime(h,m,s)
Prototype in doshk.h
Remarks makes a DOS file time stamp. Refer to a DOS
reference book (Advanced MS-DOS by Ray Duncan
recommended) for further details.
This function is a macro.
Return value returns the DOS file time stamp.
See also dosday(), doshour(), dosmonth(), dosmin(),
dossec(), dosyear(), todosdate()
TCHK 2.0 Page 227
Function tohour - converts 24-hour format to 12-hour
Syntax #include <timehk.h>
(int) tohour(hr)
Prototype in timehk.h
Remarks converts hr from 24-hour time to 12-hour time.
Return value returns the hour of the day, as would appear on a
12-hour clock (1-12).
See also isPM(), time_convert(), to24hour()
TCHK 2.0 Page 228
Function valid_date - check if a date is valid
Syntax boolean valid_date(int month, int day, int
yearnum);
Prototype in datehk.h
Remarks valid_date checks if the given date is valid.
Return value returns TRUE if the date is valid, FALSE otherwise.
See also isleapyear()
Example #include <datehk.h>
main()
{
int i, d[3] = { 11,5,2 }, m[3] = { 31,12,29};
int y[3] = { 70, 1987, 1981 };
for (i=0; i<3; ++) {
printf("%d/%d/%d ", m[i], d[i], y[i]);
if (valid_date(m[i], d[i], y[i])
printf("valid\n");
else
printf("INVALID\n");
}
}
Program output 11/31/70 INVALID /* Nov has 30 days */
5/13/1987 valid
2/29/1981 INVALID /* 1981 not a leap year */
TCHK 2.0 Page 229
Function variance - calculate the variance of a set of
reals
Syntax double variance(int n, double element[]);
Prototype in mathhk.h
Remarks variance calculates the variance of a set of n
numbers of type double.
Return value returns the variance of a set of n numbers.
See also average(), stddev(), summation()
Example #include <mathhk.h>
main()
{
double num[] = { 2.3, 7.1, 6.05 };
printf("Variance is %lf\n",variance(3,num));
}
Program output Variance is 4.245
TCHK 2.0 Page 230
Function vert_line - draw a vertical line
Syntax void vert_line(byte c, int len, int col, int row);
Prototype in video.h
Remarks draws a vertical line of characters c of length len
beginning at (col,row) via INTerrupts, using the
current char_attribute setting for color. Screen
coordinates are absolute.
horiz_line does no error checking on the passed
parameters.
Return value nothing.
See also box(), horiz_line(), restore_box(),
restore_screen(), save_box(), save_screen()
Example #include <video.h>
main()
{
vert_line('*',7,4,4); /* draw 7 *'s */
}
TCHK 2.0 Page 231
Function whereh - X-coordinate of cursor
Syntax int whereh(void);
Prototype in video.h
Remarks returns the X-coordinate (column) of the cursor's
current location via INT 0x10, Service 3.
Return value returns the X-coordinate of the cursor's current
location.
See also gotohv(), read_cursor(), wherev()
Example #include <video.h>
main()
{
printf("Cursor's column = %d\n",whereh());
}
Program output Cursor's column = 12
TCHK 2.0 Page 232
Function wherev - Y-coordinate of cursor
Syntax int wherey(void);
Prototype in video.h
Remarks returns the Y-coordinate (row) of the cursor's
current location via INT 0x10, Service 3.
Return value returns the Y-coordinate of the cursor's current
location.
See also gotohv(), read_cursor(), whereh()
Example #include <video.h>
main()
{
printf("Cursor's row = %d\n",wherev());
}
Program output Cursor's row = 4
TCHK 2.0 Page 233
#DEFINES
Most of these #defines are self-explanatory. All can be found in
the appropriate header files:
Ansihk.h
--------
Ansi color definitions. See ansihk.h for more details
Color.h
-------
DOS color definitions. See color.h for more details.
Chiphk.h
--------
Cpu types recognized by cpu_id(). See chiphk.h for more details.
Math coprocessor types recognized by ndp_id(). See chiphk.h for
more details.
Datehk.h
--------
Date types:
typedef enum { Sun, Mon, Tues, Wed, Thrus, Fri, Sat } days;
typedef enum { Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep,
Oct, Nov, Dec } months;
My date structure:
typedef struct ddate {
int dyear; /* Year - 1900 */
int dday; /* Day of month (1-31) */
months dmon; /* Month (Jan = 0) */
};
Note: the year is stored as Year - 1900. For example, if you
wanted to store 1987 in the variable d (of type struct
ddate), you would: d.dyear = 87;
Note: the months start with January as zero.
Date constants:
#define DATENULL " - - " /* empty date string */
#define DATECHAR '-' /* date delimiter char */
#define DATECHARSTR "-" /* date delim. string */
#define DATECHARTEST "/- " /* all date delimiters */
#define BASE_LEAP_YEAR 1980 /* base year for leap
year calculations */
#define BASE_JUL_YEAR 1720982.0 /* base day for Julian
Type E calcs */
TCHK 2.0 Page 234
Date macros:
#define isleap(yr) isleapyear(yr)
Doshk.h
-------
DOS types:
typedef struct BIOSParmBlock {
unsigned int BytesPerSector;
byte SectorsPerAllocUnit;
unsigned int ReservedSectors;
byte numberFATs;
unsigned int numberRootDirEntries;
unsigned int TotalSectors;
byte MediaDescriptor;
unsigned int SectorsPerFAT;
};
typedef struct BootBlock {
byte JumpInstr[3];
byte OEMinfo[9];
struct BIOSParmBlock BPB;
unsigned int SectorsPerTrack;
unsigned int numberHeads;
unsigned int numberHiddenSectors;
};
Filehk.h
--------
File types:
typedef struct filespec {
char drive;
char path[81];
char filename[13];
};
typedef struct fnameext {
char filename[9];
char ext[4];
};
File constants:
#define FNAMESIZE 96
#define PATHSIZE 100
TCHK 2.0 Page 235
Finance.h
---------
Finance macros:
#define SLD(c,s,l) straight_line_dep(c,s,l)
#define SYD(c,s,l,p) sum_year_digits_dep(c,s,l,p)
#define DDB(c,l,p) double_decline_bal_dep(c,l,p)
#define ACC_SLD(c,s,l) accum_dep(c,s,l,0,1)
#define ACC_SYD(c,s,l,p) accum_dep(c,s,l,p,2)
#define ACC_DDB(c,l,p) accum_dep(c,0,l,p,3)
Howard.h
--------
Boolean constants and macros:
#define boolean char
#define TRUE 1
#define FALSE 0
#define EQU(b1,b2) (((b1)&&(b2)) || ((!b1)&&(!b2)))
#define NEQ(b1,b2) (((b1)&&(!b2)) || ((!b1)&&(b2)))
#define BINV(b1) (b1 ? FALSE : TRUE)
Text justification:
#define NONE 0
#define LEFT 1
#define CENTER 2
#define RIGHT 3
Ibm.h
-----
IBM types:
typedef struct EMSrecord {
unsigned int handle;
unsigned int totalpages;
unsigned int availpages;
byte version;
byte emserror;
};
IBM constants:
Rom id constants. See ibm.h for more details.
Machine id constants. See ibm.h for more details.
Memory strategy constants. See ibm.h for more details.
Disk id byte constants. See ibm.h for more details.
EMS constants. See ibm.h for more details.
#define TIMER_TICKS *((long far *) 0x46Clu)
TCHK 2.0 Page 236
Keyboard.h
----------
Keyboard constants:
#define SHIFT_STATUS *((byte far *) 0x417lu)
#define WAITFORKEY 1
getget() flags:
#define BELL 0x08
#define TRIMLEFT 0x04
#define TRIMRIGHT 0x02
#define INSERTMODE 0x01
#define TRIMALL TRIMLEFT|TRIMRIGHT
#define NOFLAGS 0x00
Keyboard macros:
#define kbdclear() clear_typeahead()
Keycode.h
---------
Keycode constants:
Key shift status constants. See keycode.h for more details.
Key code constants. See keycode.h for more details.
Math.h
------
Math constants:
#define SQRT2 1.41421356237309504880
#define PI 3.141592653589793238462643
#define E 2.7182818284590452353602874
Math functions:
#define sqr(x) ((x) * (x))
#define isgn(x) ((x) < 0 ? -1 : 1)
#define lsgn(x) ((x) < 0l ? -1 : 1)
#define fsgn(x) ((x) < 0.0 ? -1 : 1)
#define sign(x) isgn(x)
#define sgn(x) isgn(x)
#define lsign(x) lsgn(x)
#define fsign(x) fsgn(x)
#define swap(x,y) (x^=y, y^=x, x^=y)
#define mid(a,x,b) ((((a) <= (x)) && ((x) <= (b))) ? 1 : 0)
TCHK 2.0 Page 237
Menuhk.h
--------
Menuhk types:
typedef struct popup_field {
char *command;
int y;
char flag;
char key;
char offset;
int retval;
struct popup_header *submenu;
struct popup_field *next;
struct popup_field *previous;
};
typedef struct popup_header {
char *videosave;
struct text_info inforec;
int left, top, right, bottom;
int margc;
struct popup_field *margv;
struct popup_field *current;
char *menusave;
int colnorm;
int colcmdkey;
int colhilite;
int coldisabled;
int coldishilite;
unsigned flags;
char internal;
};
typedef struct litebar_field {
char *command;
int x, y;
char flag;
char key;
char offset;
char *message;
int retval;
struct litebar_header *submenu;
struct litebar_field *next;
struct litebar_field *previous;
struct litebar_field *left;
struct litebar_field *right;
struct litebar_field *up;
struct litebar_field *down;
};
typedef struct litebar_header {
char *videosave;
struct text_info inforec;
TCHK 2.0 Page 238
int left, top, right, bottom;
int margc;
struct litebar_field *margv;
struct litebar_field *current;
int msgx, msgy;
char *menusave;
struct keylist *quitkey;
int colnorm;
int colcmdkey;
int colhilite;
int coldisabled;
int coldishilite;
int colmessage;
unsigned flags;
char internal;
};
typedef struct keylist {
int keyval;
struct keylist *next;
};
Menu flags:
#define QUITMENU 0x8000
#define ESCQUIT 0x4000
#define FREEMENU 0x2000
#define HIERARCHIAL 0x0100
#define CASEINDEP 0x0020
#define RESTORECURSOR 0x0010
#define CURSORON 0x0008
#define ERASEMENU 0x0004
#define DISABLEOFF 0x0002
#define WRAPAROUND 0x0001
Internal menu flags:
#define FIRSTTIME 0x01
Menu command flags:
#define ENABLED 0x00
#define DISABLED 0x01
#define NOTOPTION 0x02
#define STATICTEXT NOTOPTION
Menuhk.h constants:
#define MAXMENUCHOICES 23
TCHK 2.0 Page 239
Multihk.h
---------
Multihk types:
typedef struct DESQmemory {
int memavail;
int largestblockavail;
int totalmem;
};
Printhk.h
---------
Printhk constants:
Print Screen constants. See printhk.h for more details.
Print.com constants. See printhk.h for more details.
Print.com error codes. See printhk.h for more details.
#define PRTSC_STATUS *((byte far *) 0x500lu)
Video.h
-------
Video constants:
#define VIDEO 0x10
#define MODE *((byte far *) 0x449lu)
#define PAGE *((byte far *) 0x462lu)
#define PAGELEN *((unsigned int far *) 0x44Clu)
#define VIDOFFSET *((unsigned int far *) 0x44Elu)
#define ROWCOUNT *((byte far *) 0x484lu)
#define CHARHEIGHT *((unsigned int far *) 0x485lu)
#define CURSOR_UNDERBAR (MODE==7)?0x0B0C:0x0607
#define CURSOR_HALFBLOCK (MODE==7)?0x070C:0x0407
VARIABLE TYPES
The following variable types have been defined:
bboolean = unsigned int defined in TC.EXE. See Features.
boolean = char Howard.h
byte = unsigned char defined in TC.EXE. See Features.
word = unsigned int defined in TC.EXE. See Features.
struct ddate Datehk.h
struct BiosParmBlock Doshk.h
struct BootBlock Doshk.h
struct filespec Filehk.h
struct fnameext Filehk.h
struct EMSrecord Ibm.h
struct DESQmemory Multihk.h
TCHK 2.0 Page 240
GLOBAL VARIABLES
These variables are defined for one reason or another and used
internally. None of these variables have to be initialized (see
insertmode.) They are mainly used to return extra values found in
certain functions or needed globally by other functions.
Date variables:
char *Days[7] = { "Sunday","Monday","Tuesday","Wednesday",
"Thursday","Friday","Saturday" };
char *Months[12] = { "January","February","March","April",
"May","June","July","August",
"September","October","November",
"December" };
char *MonthAbbr[12] = { "Jan","Feb","Mar","Apr","May",
"Jun","Jul","Aug","Sep","Oct",
"Nov","Dec" };
int daylist[13] = { 0, 31, 59, 90, 120, 151, 181, 212,
243, 273, 304, 334, 365 };
Note: daylist is a list of the day number of the year at the end
of each month (i.e. April 1st is the 91st (Mar 31 = 90, +1)
day of the year.)
Keyboard variables:
boolean key_extended; /* TRUE if special key pressed,
i.e. Alt-X, etc. */
int key_status; /* shift key status byte */
Note: these variables are set by inkey() and getk(), and are
checked by many other keyboard routines.
boolean insertmode; /* insert or overwrite mode? */
Note: This variable is used internally by getstr() and getget().
Although getget() initializes this variable, getstr does
NOT. You MUST set insertmode to TRUE or FALSE before
calling getstr() or unpredictable results may occur. Upon
completion of this function, testing this variable will
determine the input mode last used. Future versions will
default insertmode to some value if it has not been set.
Multitasking variables:
char _dvmajor;
char _dvminor;
TCHK 2.0 Page 241
TCHK version variables:
unsigned int _TCHKversion = 0x0200;
unsigned char _TCHKmajor = 2;
unsigned char _TCHKminor = 00;
char *_TCHKdate = "12/03/88";
char *_TCHK = "TCHK is Copyright (C) 1988 by Howard
Kapustein. All rights reserved.";
Video variables:
FRAMES: see video.h for frame[] declarations.
const char emptystring[] = " ";
Note: Do NOT alter this variable. emptystring[] is defined
as a string of 15 spaces and is used internally by
several functions. Altering this function can lead to
wildly unpredictable results.
byte char_attribute;
Note: This variable is used by many output functions to set
the attribute byte. For functions such as putstr() you
can either call set_color() with the attribute desired
or declare char_attribute as an extern and then set it
yourself.
TCHK 2.0 Page 242
REVISION HISTORY
Version 2.0 - 12-3-88
-----------
Compiled with Turbo C 2.0
New functions:
- ansiback(), ansifore()
- DESQcommonmem(), DESQconvenmem(), DESQdispchar(), DESQexit(),
DESQexpandedmem(), DESQInternalStack(), DESQMakeTone(),
DESQProgramStack()
- DoubleDOSGetVirtual()
- EMSinfo(), EMSpages(), EMSwarmbootprep(), getEMSstatus()
- inkeyc()
- strclean(), strcapital(), strfill(), stroccur(),
strtocomma(), strwcmp(), strwicmp()
- cpu_id(), ndp_id() (ndp_id() is not 100% bug free yet)
- diskchanged()
- isBlogical(), isgameport(), iskey102()
- CapsLock(), InsLock(), NumLock(), ScrollLock()
- tocapkey()
- accum_dep(), depreciation(), double_decline_bal_dep(),
striaght_line_dep(), sum_year_digits_dep()
- FV(), FVa(), PMT(), PV(), PVa()
- average(), factorial(), stddev(), summation(), variance()
- frac(), round()
- expandfilespec(), fncmp(), getfilespec(), isdir(),
parsefilename(), parsefnameext()
- beep()
- boxwindow()
- isPM(), to24hour(), tohour()
- time_convert()
- getcursor(), setcursor()
- color()
- read_attrib(), read_char()
- settextinfo()
- endstri(), endstrp()
- pause()
- print_screen()
- isPRINTavail(), PRINTadd(), PRINThold(), PRINTpurge(),
PRINTremove(), PRINTresume()
- isAssignavail(), isAppendavail(), isShareavail(),
isVidclock()
- getBootBlock(), getBPB()
- menu_popup(), popup_alloc(), popup_free(), popup_get()
- popup_restore(), popup_setcurrent(), pophilite(), popunlite()
- litebar_alloc(), litebar_free(), litebar_get()
- changelitebar(), litehilite(), litemessage(), liteunhilite()
- dosday(), doshour(), dosmonth(), dosmin(), dossec(),
dosyear(), todosdate(), todostime()
- mid(), sqr(), swap()
- fsgn(), isgn(), lsgn()
- framebox[], emptystring[], _dvmajor, _dvminor, _TCHKversion,
_TCHKmajor and _TCHKminor variables
TCHK 2.0 Page 243
Changes:
- screen coordinates format now (x,y) starting at (1,1)
- atrim(), ltrim() and rtrim() now modify the string passed to
them
- box(), clear(), cls()
- ddatetolong() renamed to ddatetofull()
- EMMversion() modified
- getc_match(), getci_match() previously were getk_match() and
getc_match()
- virtually all get...() functions now use Borland's console
i/o routines
- gotoxy() renamed to gotohv()
- isBREAKon(), isVERIFYon(), setBREAK(), setVERIFY() are now
#defines
Removed:
- delay() removed
- isleap() removed
- restore_box(), restore_screen(), save_box(), save_screen()
removed
- max() and min() #defines removed (Borland now supplies them)
If I've missed a couple, forgive me. I think I got them all down,
but with all the changes and additions, it's hard to be 100% sure.
Note: The ndp(), menu_lotus() and lotus_setup() functions are not
fully implemented yet. The ndp() seems to crash the machine,
and I found something grievously wrong with the lotus
functions while testing the demo. Due to previous
commitments, I am forced to release the library with these
defective functions. Look for the working versions in the
next release.
Version 1.5 - Internal release only
-----------
Version 1.0 - Internal release only
-----------
Version 0.70 - 2-17-88
------------
New functions:
- date_convert()
- machine_id()
- fname_match()
I rewrote the License agreement after several conversations with
Robert Blacher. He pointed out, rightly so, that the old
licensing information was a bit confusing.
Fixed a bug in shorttoddate() and fulltoddate(). These functions
required a proper month abbreviation. If you had "Mau 12,
TCHK 2.0 Page 244
1987" instead of "May 12, 1987" it would get stuck in an
endless loop.
Fixed a bug in some of the date conversion functions. A few
functions refer to a list of the day number at the end of a
month. This list (daylist[] in this version) listed Jun 30 as
the 182nd day of the year instead of the 181st day of the
year. The only inaccurate dates would be those occurring
between July 1 and July 30, inclusive, and these would only
be ahead by 1 day. Only those date functions with english in
them (shorttoddate(), ddatetofull(), etc.) are affected.
Found the proper way to check for DESQview. DESQversion() now
returns the version of DESQview in the high and low order
bytes. See DESQversion() for more details.
Changed the #define BASE_JUL_YR to a double to prevent loss of
significant digits warning message.
Restructured the global variables. With version 0.70, most
of the global variables are declared separately from the code
itself. If you use, say, Months[], but nothing else, only
Months[] will get linked in to your program instead of
pulling a whole bunch of functions with it. When I get TC 1.5
I hope to break up the functions even more.
Added MonthAbbr[] and DayList[] global variables
Fixed the disktype() function. It would plain not work. It would
get a word and return a byte (the wrong byte, of course.) God
curse all typos.
Changed the DemoDisk sample program as well (no more DISK_ERROR,
now it's DISK_INVALID. See the #define section for more
details.)
Expanded the list of Rom id bytes. See the #define section for
more details.
Cleaned up some typos in the documentation.
Version 0.60 - 1-15-88
------------
Over 30 new functions added:
- Cal...(), Greg...(), Jul...(), fulltoddate(), shorttoddate()
- dayofweek()
- isBREAKon(), setBREAK()
- isVERIFYon(), setVERIFY()
- reboot()
- isExtended(), Extendedtotal(), EMMversion()
- isNetwork()
- memory_strategy()
- disktype()
- set_handles()
- DESQversion(), DESQfreeCPU()
- isDoubleDOS(), DoubleDOSTaskSwitch(), DoubleDOSfreeCPU()
- scrbuff()
- cursor_blink()
- ansi_call()
Fixed a bug in isleapyear(). Previously, isleapyear() would
determine years ending in 00 that were evenly divisible by 4
to be leap years (i.e. 1600). The gregorian calendar (you
TCHK 2.0 Page 245
know, 30 days hath September...) doesn't count those as leap
years.
Optimized the direct video access routines as well as possible
using 100% C code. Previously they checked for vertical
retrace. Now all direct accesses play with the video
registers and other fun things, basically turning off the
screen for a fraction of a second, performing the access,
then turning the screen back on again. In the longer access
functions (save_screen() to name one) I found changing 30
bytes between screen blankings to be optimal. These changes
have sped up the direct video access functions (putsay(),
save_...(), restore_...()) by a factor or 3! These functions
now take 1/3 the time they used to. If you find the screen to
blink, or that there is snow (putsay() may experience
miniscule snow when outputting long strings) please let me
know and I'll see what I can do.
Version 0.50 - 11-18-87
------------
Initial release of TCHK
FUTURE ENHANCEMENTS
There are more functions on the way. If you have any favorites you
would like to see, or need, drop me a line. In future releases,
look for the following features:
- fixing the ndp() function
- updating the Lotus style menus along the lines of the
current popup and litebar menus
- enhancement of the get and put routines to support all
features found in the @...SAY...GET commands of dBase III+
- keyboard routines using scan codes
- more menu interfaces (pulldown, hierarchial)
- mouse functions
- sound functions
- more EMS functions
- several math functions (integration, numerical methods, +)
- some more accounting functions to have a well rounded
accounting library
- access to dBASE III+ files (.DBF, perhaps .NDX and .MEM)
- software id functions (TSR, ANSI.SYS, VDISK.SYS, etc.)
- direct screen accesses coded in assembler
- enhancement of the put routines to support the 'backslash'
control characters like printf does (\n, \t, etc.)
- some more video routines
TCHK 2.0 Page 246
OTHER PRODUCTS
I am also the author of the following products:
COOKIE 1.2 - Fortune cookie, gives you a random fortune from a
cookie file. Lots of options and distributed with
2800 cookies of mixed content (rated G - X)
DCOUNT 1.2 - Document/Text file info, find out all kinds of
information like # words, lines, pages, control
characters, etc. Many options.
FREE 1.4 - Free disk space, with options. Distributed with
full Turbo C source.
SF 3.01 - Subtree Find, a powerful directory searcher. SF's
main claim to fame is being able to search a branch
of a disk directory, from a single directory to an
entire disk, 5%-250% faster than the leading file
finders! Other features include displaying more
information than DIR, delete files, color output,
pause during display, permanently modify options,
and much much more. Written in Turbo C 2.0.
SUPPORT
Thanks to the graciousness of the sysop at The BOSS, I now have
easier access to his BBS. The latest versions of my software can
be found there.
If there are some features you would like to see implemented, or
you have any questions or comments, please contact me. I can be
reached at the following:
HOME COLLEGE
──── ───────
Howard Kapustein Howard Kapustein
1695 Barbara Lane 404 Davison Hall
East Meadow, NY 11554 Rensselaer Polytechnic Institute
Phone: (516) 481-9612 Troy, NY 12180
Phone: (518) 276-7381
or at the following electronic services/bulletin boards:
The Boss dBBS (201) 568-7293 *** Support BBS ***
Software Society (201) 729-7410 Distribution BBS
Computer Connection (202) 547-2008 Distribution BBS
These are the places I can be reached by modem. TCHK (and all
other software I release) is supported through The BOSS.
TCHK 2.0 Page 247
If you try to get in touch with me during the school year (roughly
Sep 1 - May 10, not counting winter break of Xmas - Jan 15) PLEASE
try to reach me at college. If you call my home odds are you won't
get much information. My parents aren't exactly what you would
call computer people.
TCHK 2.0 Page 248
APPENDIX A - DATE FORMATS
The following date formats are supported by TCHK:
TCHK Reference Date Type Format
-------------- --------- ------
Greg Gregorian (US) MM-DD-YY
GregEuro Gregorian (European) DD-MM-YY
GregJap Gregorian (Japan) YY-MM-DD
Cal Calendar YYMMDD
CalCent Calendar (w/Century) YYYYMMDD
Jul Julian (Type E) special hashed number
JulA Julian (Type A) YYDDD
JulB Julian (Type B) YYYYDDD
full English (Full) Month DD, YYYY
short English (Short) Mon DD, YYYY
ddate struct ddate see datehk.h
- Gregorian units are common shorthand dates (in string format)
with all leading zeros preserved
- Calendar units are numeric representations (double)
- Julian Type E is a special "magic" hashed number (double)
representing the number of elapsed days since an initial date.
Julian Type E numbers are valid for the years 1900-2100 (give
or take a couple of months)
- Julian Type A and B are ANSI defined formats (double)
containing year (and century for type B) and the day of the
year
- full are strings of the date with the full name of the month
- short are strings of the date with the short abbreviation of
the month
- ddate is my own date structure defined in datehk.h
In some instances date formats not specifically designed to hold
the century may overflow. For example, converting CalCent
formatted 20220401 (April 1, 2022) to Greg (MM-DD-YY) would
result in the string "04-01-122". Be aware.
! ! ! WARNING ! ! !
Unless otherwise specified, date format conversion functions
(GregtoCal, JulAtoddate, etc.) do NOT perform error checking. If
you pass an invalid date (March 32, 1988) your result may be
logically incorrect even though syntactically correct (Gregorian
date of 03/32/88) or be totally corrupted.
Julian Type E numbers are valid for the years 1900-2100 (give or
take a couple of months.)
TCHK 2.0 Page 249
APPENDIX B - date_convert() FORMATS
The following formats are supported by date_convert():
Type (id) Data Type Format Notes
--------- --------- ------ -----
1 char MM-DD-YY US
2 " DD-MM-YY Europe
3 " YY-MM-DD Japan
4 double YYMMDD Calendar
5 " YYYYMMDD " w/cent
6 " hashed Julian Type E
7 " YYDDD " Type A
8 " YYYYDDD " Type B
9 struct date see dos.h
10 struct ddate see datehk.h
11 char Mon DD, YYYY short, no lead 0
12 " Month DD, YYYY full, no lead 0
13 " MM/DD/YY US
14 " DD/MM/YY Europe
15 " YY/MM/DD Japan
16 " MM-DD-YY no lead 0
17 " DD-MM-YY "
18 " YY-MM-DD "
19 " MM/DD/YY no lead 0
20 " DD/MM/YY "
21 " YY/MM/DD "
22 " MM-DD-YYYY century
23 " DD-MM-YYYY "
24 " YYYY-MM-DD "
25 " MM/DD/YYYY century
26 " DD/MM/YYYY "
27 " YYYY/MM/DD "
28 " MM-DD-YYYY century, no lead 0
29 " DD-MM-YYYY "
30 " YYYY-MM-DD "
31 " MM/DD/YYYY century, no lead 0
32 " DD/MM/YYYY "
33 " YYYY/MM/DD "
TCHK 2.0 Page 250
34 char DD-MON-YY
35 " DD-MON-YY no lead 0
36 " DD-MON-YYYY century
37 " DD-MON-YYYY " no lead 0
38 " Mon DD, YYYY short
39 " Month DD, YYYY full
40 " DD MON YY
41 " DD MON YY no lead 0
42 " DD MON YYYY century
43 " DD MON YYYY " no lead 0
Unless otherwise specified, a date format contains leading zeros.
Refer to date_convert() for further specifications.
TCHK 2.0 Page 251
APPENDIX C - time_convert() FORMATS
The following formats are supported by time_convert():
Type (id) Data Type Format Notes
--------- --------- ------ -----
1 char HH:MM AM 12-hour (h,m)
2 " HH:MM 24-hour (h,m)
3 " HH:MM:SS AM 12-hour (h,m,s)
4 " HH:MM:SS 24-hour (h,m,s)
5 " HH:MM:SS:CC AM 12-hour (h,m,s,u)
6 " HH:MM:SS:CC 24-hour (h,m,s,u)
7 struct time see dos.h
8 double 1/100 seconds
9 " seconds
10 " minutes
11 " hours
12 " days
13 char HHhMMm no leading zeros
14 " HHhMMmSSs no leading zeros
15 " HHhMMmSSsCCc no leading zeros
16 " 0HH:MM AM 12-hour (0h,m)
17 " 0HH:MM 24-hour (0h,m)
18 " 0HH:MM:SS AM 12-hour (0h,m,s)
19 " 0HH:MM:SS 24-hour (0h,m,s)
20 " 0HH:MM:SS:CC AM 12-hour (0h,m,s,u)
21 " 0HH:MM:SS:CC 24-hour (0h,m,s,u)
22 " 0HHhMMm all leading zeros
23 " 0HHhMMmSSs all leading zeros
24 " 0HHhMMmSSsCCc all leading zeros
The notation H:M:S:C stands for hours:minutes:seconds:centiseconds
(1/100 secs). The notation AM stands for AM or PM, as is
appropriate.
Unless otherwise specified, a time string contains leading zeros
for all values except the hour. The notation 0H stands for hours
containing leading zeros.
Refer to time_convert() for further specifications.
TCHK 2.0 Page 252
Index
_dvmajor 240, 242
_dvminor 240, 242
_TCHK 241, 242
_TCHKdate 241
_TCHKmajor 241, 242
_TCHKminor 241, 242
_TCHKversion 241, 242
A
Accum_dep 1, 14, 44, 64, 201, 218, 235, 242
Ansiback 1, 16, 17, 18, 242
Ansifore 1, 16, 17, 18, 242
Ansi_call 1, 15, 17, 18, 244
Atrim 1, 19, 243
Average 1, 20, 200, 219, 229, 242
B
Beep 1, 21, 242
BIOSParmBlock 85, 234
BootBlock 84, 234, 239
Box 1, 10, 13, 22, 23, 24, 28, 104, 129, 130, 156,
187, 188, 230, 242, 243
Boxwindow 1, 22, 23, 24, 129, 156, 242
C
Cal... 1, 25, 37, 41, 42, 43, 81, 103, 127, 148, 198,
213, 244
CapsLock 1, 26, 108, 150, 189, 242
Changelitebar 1, 27, 132, 133, 134, 135, 136, 137, 242
Char_attribute 104, 171, 172, 173, 190, 230, 241
Clear 1, 15, 28, 29, 30, 236, 243
Clear 1, 15, 28, 29, 30, 236, 243
Clear_typeahead 1, 29, 236
Cls 1, 15, 28, 30, 243
Color 1, 3, 4, 5, 9, 10, 15, 16, 17, 18, 23, 31,
104, 113, 130, 135, 137, 143, 157, 163, 164,
171, 172, 173, 190, 230, 233, 241, 242, 246
Cpu_id 1, 32, 141, 149, 233, 242
Cursor_blink 1, 33, 34, 35, 36, 88, 178, 191, 195, 244
Cursor_flip 1, 33, 34, 35, 36, 88, 178, 191, 195
Cursor_off 1, 33, 34, 35, 36, 88, 178, 191, 195
Cursor_on 1, 33, 34, 35, 36, 88, 178, 191, 195
D
Date_convert 1, 6, 25, 37, 41, 42, 43, 81, 103, 127, 148,
198, 213, 243, 249, 250
Daylist 240, 244
Dayofweek 1, 38, 39, 244
Dayofyear 1, 39, 40, 55
Days 1, 39, 40, 43, 55, 120, 228, 233, 240, 245,
248, 251
TCHK 2.0 Page 253
Days 240
Daysleft 1, 39, 40, 55
Ddate 1, 25, 37, 39, 40, 41, 42, 43, 55, 81, 103,
127, 148, 198, 213, 233, 239, 243, 244, 248,
249
Ddatetofull 1, 25, 37, 41, 42, 43, 81, 103, 127, 148, 198,
213, 243, 244
Ddatetoshort 1, 25, 37, 41, 42, 43, 81, 103, 127, 148, 198,
213
Ddatetostr 1, 25, 37, 41, 42, 43, 81, 103, 127, 148, 198,
213
Depreciation 1, 14, 44, 64, 201, 218, 242
DESQcommonmem 1, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 242
DESQconvenmem 1, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 242
DESQdispchar 1, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 242
DESQexit 1, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 242
DESQexpandedmem 1, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 242
DESQfreeCPU 2, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 244
DESQInternalStack 2, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 242
DESQMakeTone 2, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 242
DESQmemory 45, 46, 49, 239
DESQProgramStack 2, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 242
DESQversion 2, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 244
Diffddate 2, 39, 40, 55
Diskchanged 2, 56, 57, 242
Disktype 2, 9, 56, 57, 244
Dosday 2, 58, 59, 60, 61, 62, 63, 225, 226, 242
Doshour 2, 58, 59, 60, 61, 62, 63, 225, 226, 242
Dosmin 2, 58, 59, 60, 61, 62, 63, 225, 226, 242
Dosmonth 2, 58, 59, 60, 61, 62, 63, 225, 226, 242
Dossec 2, 58, 59, 60, 61, 62, 63, 225, 226, 242
Dosyear 2, 58, 59, 60, 61, 62, 63, 225, 226, 242
DoubleDOSfreeCPU 2, 65, 66, 67, 244
DoubleDOSGetVirtual 2, 65, 66, 67, 242
DoubleDOSTaskSwitch 2, 65, 66, 67, 244
Double_decline_bal_dep 2, 14, 44, 64, 201, 218, 235, 242
E
EMMversion 2, 68, 69, 70, 71, 91, 115, 243, 244
Emptystring 241, 242
EMSinfo 2, 69, 115, 242
EMSpages 2, 68, 69, 70, 71, 91, 115, 242
EMSrecord 69, 70, 235, 239
EMSwarmbootprep 2, 68, 69, 70, 71, 91, 115, 242
Endstri 2, 72, 73, 242
Endstrp 2, 73, 242
Expandfilespec 2, 74, 242
Extendedtotal 2, 75, 116, 244
F
Factorial 2, 76, 219, 242
Filespec 2, 12, 74, 92, 151, 152, 234, 239
Fnameext 153, 234, 239
Fname_match 2, 77, 78, 243
TCHK 2.0 Page 254
Fncmp 2, 77, 78, 242
Frac 2, 79, 184, 242, 245
Fsgn 2, 80, 118, 138, 236, 242
Fulltoddate 2, 25, 37, 41, 42, 43, 81, 103, 127, 148, 198,
213, 243, 244
FV 2, 82, 83, 155, 174, 175, 242
FVa 2, 82, 83, 155, 174, 175, 242
G
GetBootBlock 2, 84, 85, 242
GetBPB 2, 84, 85, 242
Getci_match 2, 87, 98, 243
Getcursor 2, 33, 34, 35, 36, 88, 178, 191, 195, 242
Getc_match 2, 86, 87, 97, 98, 101, 105, 106, 243
Getdatehk 2, 89
Getdouble 2, 90, 96, 99
GetEMSstatus 2, 68, 69, 70, 71, 91, 115, 242
Getfilespec 2, 74, 92, 152, 153, 242
Getfname 2, 93
Getget 2, 93, 94, 100, 236, 240
Getint 2, 90, 96, 99
Getk 2, 86, 87, 97, 98, 101, 105, 106, 240, 243
Getlogical 2, 86, 87, 97, 98, 101, 105, 106
Getreal 2, 90, 96, 99
Getstr 2, 95, 100, 240
Getyn 2, 86, 87, 97, 98, 101, 105, 106
Gotohv 2, 22, 28, 102, 171, 173, 231, 232, 243
Greg... 2, 25, 37, 41, 42, 43, 81, 103, 127, 148, 198,
213, 244
H
Horiz_line 2, 22, 23, 104, 230
I
Inkey 3, 29, 86, 87, 89, 90, 94, 95, 96, 97, 98, 99,
100, 101, 105, 106, 131, 157, 223, 240, 242
Inkeyc 3, 97, 98, 101, 105, 106, 131, 157, 223, 242
Insertmode 236, 240
InsLock 3, 26, 108, 150, 189, 242
Intlen 3, 107
IsAppendavail 3, 109, 110, 124, 242
IsAssignavail 3, 109, 110, 124, 242
IsBlogical 3, 111, 242
IsBREAKon 3, 112, 125, 194, 197, 243, 244
IsCGA 3, 113
Iscolor 3, 113
Isdir 3, 74, 114, 242
IsEGA 3, 113
IsEMSavail 3, 68, 69, 70, 71, 91, 115
IsExtended 3, 75, 116, 244
Isgameport 3, 117, 242
Isgn 3, 80, 118, 138, 236, 242
IsHerc 3, 113
Iskey102 3, 119, 242
TCHK 2.0 Page 255
Isleapyear 3, 37, 120, 228, 234, 244
IsMDA 3, 113
Ismono 3, 113
IsNetwork 3, 121, 244
IsPM 3, 123, 224, 227, 242
IsPRINTavail 3, 122, 165, 166, 167, 168, 169, 170, 242
IsShareavail 3, 109, 110, 124, 242
IsVERIFYon 3, 112, 125, 194, 197, 243, 244
IsVidclock 3, 126, 242
J
Jul... 3, 25, 37, 41, 42, 43, 81, 103, 127, 148, 198,
213, 244
K
Keylist 131, 238
Key_extended 97, 240
Key_status 97, 240
L
Leftstr 3, 128, 147, 181
Litebar_alloc 3, 27, 129, 133, 134, 135, 136, 137, 242
Litebar_field 27, 237, 238
Litebar_free 3, 27, 131, 132, 133, 134, 135, 136, 137, 242
Litebar_get 3, 27, 131, 132, 133, 134, 135, 136, 137, 242
Litebar_header 27, 129, 132, 133, 134, 135, 136, 137, 237
Litehilite 3, 27, 132, 133, 134, 135, 136, 137, 242
Litemessage 3, 27, 132, 133, 134, 135, 136, 137, 242
Liteunlite 3, 132, 133, 134, 135, 136, 137
Lotus_setup 3, 140, 144, 243
Lsgn 3, 80, 118, 138, 236, 242
Ltrim 3, 139, 243
M
Machine_id 3, 32, 141, 149, 182, 183, 243
Memory_strategy 3, 142, 244
Menu_lotus 3, 140, 143, 144, 243
Menu_popup 3, 145, 158, 159, 160, 161, 162, 163, 164, 242
Mid 3, 128, 146, 147, 181, 224, 236, 242
Midstr 3, 128, 147, 181
MonthAbbr 148, 240, 244
Monthexpand 3, 25, 37, 41, 42, 43, 81, 103, 127, 148, 198,
213
Months 148, 240, 244
Months 8, 43, 132, 148, 158, 233, 240, 244, 248
N
Ndp_id 3, 32, 141, 149, 233, 242
NumLock 3, 26, 108, 150, 189, 242
P
Parsefilename 3, 74, 92, 151, 152, 153, 242
Parsefnameext 3, 74, 92, 152, 153, 242
Pause 3, 154, 242, 246
TCHK 2.0 Page 256
PMT 3, 82, 83, 155, 174, 175, 242
Pophilite 4, 145, 158, 159, 160, 161, 162, 163, 164, 242
Popunlite 4, 145, 158, 159, 160, 161, 162, 163, 164, 242
Popup_alloc 3, 145, 156, 159, 160, 161, 162, 163, 164, 242
Popup_field 237
Popup_free 3, 145, 157, 158, 159, 160, 161, 162, 163,
164, 242
Popup_get 3, 145, 157, 158, 159, 160, 161, 162, 163,
164, 242
Popup_header 156, 158, 159, 160, 161, 162, 163, 164, 237
Popup_restore 4, 145, 158, 159, 160, 161, 162, 163, 164, 242
Popup_setcurrent 4, 145, 158, 159, 160, 161, 162, 163, 164, 242
PRINTadd 4, 122, 165, 166, 167, 168, 169, 170, 242
PRINThold 4, 122, 165, 166, 167, 168, 169, 170, 242
PRINTpurge 4, 122, 165, 166, 167, 168, 169, 170, 242
PRINTremove 4, 122, 165, 166, 167, 168, 169, 170, 242
PRINTresume 4, 122, 165, 166, 167, 168, 169, 170, 242
Print_screen 4, 165, 242
Putk 4, 22, 28, 86, 171, 172, 173, 190
Putsay 4, 171, 172, 173, 245
Putstr 4, 98, 101, 171, 172, 173, 190, 241
PV 4, 82, 83, 155, 174, 175, 242
PVa 4, 82, 83, 155, 174, 175, 242
R
Read_attrib 4, 176, 177, 242
Read_char 4, 176, 177, 242
Read_cursor 4, 33, 34, 35, 36, 88, 102, 178, 191, 195,
231, 232
Read_mode 4, 179, 193
Reboot 4, 10, 11, 180, 244
Rightstr 4, 128, 147, 181
ROM_date 4, 141, 182, 183
ROM_id 4, 141, 182, 183
Round 2, 4, 79, 184, 214, 242, 245
Rtrim 4, 185, 243
S
Scrbuff 4, 23, 24, 186, 244
ScrollLock 4, 26, 189, 242
Scroll_down 4, 187, 188
Scroll_up 4, 187, 188
SetBREAK 4, 112, 125, 194, 197, 243, 244
Setcursor 4, 33, 34, 35, 36, 88, 178, 191, 195, 242
Settextinfo 4, 131, 157, 196, 242
SetVERIFY 4, 112, 125, 194, 197, 243, 244
Set_color 4, 171, 172, 173, 190, 241
Set_cursor 4, 33, 34, 35, 36, 88, 178, 191, 195
Set_handles 4, 192, 244
Set_mode 4, 15, 179, 193
Shorttoddate 4, 25, 37, 41, 42, 43, 81, 103, 127, 148, 198,
213, 243, 244
Sqr 4, 199, 236, 242
Stddev 4, 20, 200, 219, 229, 242
TCHK 2.0 Page 257
Straight_line_dep 4, 14, 44, 64, 201, 218, 235
Strcapital 4, 202, 242
Strclean 4, 203, 242
Strcomma 4, 107, 204, 212
Strdel 4, 205
Strfill 4, 206, 242
Strins 4, 207
Stroccur 4, 208, 242
Strrep 4, 206, 209
Strshleft 4, 210
Strshright 4, 211
Strtocomma 4, 204, 212, 242
Strtoddate 4, 25, 37, 41, 42, 43, 81, 103, 127, 148, 198,
213
Strtodol 4, 214
Strtotime 5, 215, 221, 222
Strwcmp 5, 216, 217, 242
Strwicmp 5, 216, 217, 242
Summation 5, 20, 76, 200, 219, 229, 242
Sum_year_digits_dep 5, 14, 44, 64, 201, 218, 235, 242
Swap 5, 220, 236, 242
T
Timetostr 5, 215, 221, 222
Time_convert 5, 6, 123, 221, 224, 227, 242, 251
To24hour 5, 123, 224, 227, 242
Tocapkey 5, 105, 106, 223, 242
Todosdate 5, 58, 59, 60, 61, 62, 63, 225, 226, 242
Todostime 5, 58, 59, 60, 61, 62, 63, 225, 226, 242
Tohour 5, 123, 224, 227, 242
V
Valid_date 5, 120, 228
Variance 5, 20, 200, 219, 229, 242
Vert_line 5, 22, 23, 104, 230
W
Whereh 5, 102, 178, 231, 232
Wherev 5, 102, 178, 231, 232
TCHK 2.0 Page 258
Function
Syntax
Prototype in
Remarks
Return value
Note
See also
Example
Program output